Ranking Integers Numerically But Keeping Their Order


I’m struggling to figure out how to give numerical ranks to a structured list of integers. I need keep them in their current order so they can refer back to another list. For example, (1.32,-33.43, 22.22) would return (2, 1, 3) or (4.33, 4.22) would return (2,1). See screenshot below. Anyone have a method for this?

See attached.

srt.dyn (10.2 KB)

List.SortByKey((1..List.Count(a<1>))<1>, a<1>)["sortedList"];


I like both of these methods but neither of them are keeping the right order. Is that because my input data is coming from a “double”? Hmm…see screenshot below:

Nothing to do with data type. :slight_smile:

srt.dyn (10.4 KB)

List.IndexOf(List.Sort(a<1>)<1>,a<1>) + 1;

1 Like

I think you’ve got it backwards. It doesn’t show you the place of that index, it shows you the index of that place. The list is already sorted from lowest to highest and is showing you the index that was sorted.

This is the same as this:

To get the new index of the existing order you would have to compare the sorted order to the previous order.

1 Like

@Vikram_Subbaiah This worked - thank you so much for this

@Nick_Boyts Still pretty new to dynamo so i’m going to have to sit with this information. Thank you for your help in explaining. Best regards