Sorting a calculation made from Room Areas by their referential Room Number

Hello Everyone,

I’m fairly new to dynamo, and also searched around the forum before coming here, but I’m trying to sort a list of results I have from some calculations by their respective Room Number, but can’t seem to do so using SortByKey like in this link below. Export select information from excel to family parameters of revit

For reference, I created a watch list for room names and numbers in the random way the results are showing, to show you what order they’re in now. Below that, the actual order of the rooms in the schedule that I want the results to be sorted by.

The information necessary to achieve those calculations (Results Order) come from an excel file, I don’t want to interfere on that file too much, because I want this code to be used in different projects, where the only thing the user would need to comply to is naming the room correctly.

Also, let me know if I need to make more screen shots for better understanding on what’s been done.

Thank you!

You can use List.SortIndexByValue to get the indices of your room numbers by ascending order.
Then use that to get your Rooms by the same order.

It looks like you’re just using the wrong keys.

Thank you for the help! But in your solution I still need to manually put the order I want right?

That’s what I’m trying to avoid. I was able to achieve this result doing a list reorder as well, but I have to write down the order I want. Because this will serve more than one project, I wanted that to be automatically. I tried using GetItemAtIndex but because it reads the number I have and searches in the levels (0,1…) it doesn’t get the result I need.

Maybe if there’s a way to extract the levels numbers in the sorted list and not the actual numbers that would solve my problem.

That was exactly it! The problem was that I needed to transform the list into numbers, and that did it!! So simple, but I cracked my head because of it haha. Thank you for the tip!