Sorting by keys

Hi, I’m trying to get a list of levels in order of elevation level. I’m using the sort by key node but it’s not working how i’d expect.

I have a list of levels which are not listing in order of elevation due to the level names.
I can get around this by performing a get level elevation node and then sort by natural ordering to get the elevations in order. This now becomes my keys. I now plug in my keys to the list sort by key (keys) input. I now insert the original levels that are out of order into the keys. However this returns the list in the same order.
Does anyone know why? When i watch the sorted list vs the sorted keys i get different results also. I was not expecting this result. key%20sort

hello @DynamoCanDo
on the node of List.SortByKey, at Keys input : make it @ Level 2

after level elevation put two times the node SortIndexByValue


1 Like


Thank you guys I appreciate it. I’m really pleased I asked this as I’ve been playing around with this for quite sometime now. The method from Nico worked for me. But thank you for all the suggestions. I’m wondering why this happened in the first place? Maybe Revit sorts the levels into the order in which they were created. So for the levels that were out of order these may have been created out of sequence. It appears by performing a “sort index by value” twice managed to override the erroneous sequence “in order of creation”. I maybe incorrect here but this is what it seems like?

Thanks again. Nice job.

1 Like

If a comment solved your problem, please mark it as solution so it can help others with a similar problem (and maybe leave a like here and there).