How to Sort by Name THEN Number?

Im trying to set up a system that will sort a list by Name then a Number.

Example of what Im starting with:

Hall 2
Room 1
Hall 1
Stair 2
Hall 3
Stair 1
Room 2

What I WANT to happen:

Hall 1
Hall 2
Hall 3
Room 1
Room 2
Stair 1
Stair 2

What is happening in the script image below:

Hall 2
Hall 2
Hall 3
Room 2
Room 1
Stair 1
Stair 2

I can get my Lists sorted by one value but I cant get it to sort by Value 1, THEN Value 2. I can only get it to sort by one or the other.

REVIT-EXCEL IMPORT EXPORT GRAPH 2.dyn (73.9 KB)

Thanks!

You definitely need to upload a higher quality image. But, from what it sounds like, this should do the trick.

Also, if it is the room name and room number parameters you are trying to sort by; simply use element.name to sort by key.

1 Like

Thank you for the suggestion, Will this work if I am taking multiple Parameter values and combining them into one list?

Also how do you export a higher res image? I only have the option for the png you see above

I use a screen capture tool and drag by Dynamo window across both monitors. Outlined here http://sixtysecondrevit.blogspot.com/2015/07/better-screenshots-in-dynamo.html

Which do you have in mind?

Ok here is a better image for you, If you look near the beginning I am sorting by “Department” and then doing a SortByKey, but this only sorts the departments, I am looking to then sort by the Room number under each Department

Maybe this will help explain a little more of what I am shooting for.

When I have exported to Excel first column is sorted but the Third column (Room Numbers) are in no particular order and I would like to have the Room Numbers sorted numerically.

This is not very fool proof, but if you sort the number first then the name it should work.

@john_pierson I believe I have recreated your suggestion but its not working the same for me.

@Monkey_Puppet Thank you! That works, when I tried something similar previously I was sorting by “0” first, but sorting by the second value first was the solution!

Proof of Success! For now… :smiley:

Hi Jb,

You need to install Ampersand package to get “List.GroupByKey” node. It is a custom node. Currently your feeding OOTB node “List.GroupByKey”.

1 Like

SortRooms.dyn (8.0 KB)

1 Like