Sorting list based on several variables

I want to sort a list based on several variables, and they all have their own importance.
In this case I have 3 levels of “importance” (all are just lists of values).


The top list is the list (of lists) that needs to be sorted.
Beneath that are the lists of values that it needs to be sorted on, the “importance” of them from top to bottom. Currently, the top one has all the same values (that won’t be the case in all situations) so the order can stay the same. In the second list the lowest value is at first position so that needs to move towards the top.
For the third list that would mean that that one would change in order to:
650
1250
1100
650
and the last 3 would need to get sorted based only on the last 3 values. as the first value is already “split” from them because of the sorting from the second list.

I hope I am making sense.

Thanks in advance!

I could, but the list isn’t actually sorted based on anything within the list.

Let me give you an example instead (the original list doesn’t really matter as in the end I’m more than anything after a list of indices).


I hope this somewhat clears things up.

This might work amazingly but I don’t have a clue how to attach it to how Dynamo currently works.

An example of using “itemgetter”:
image

The package “operator” should be usable in the IronPython environment.
The following is from the documentation of IronPython in regards to sorting:

For your information: I don’t know anything about Python, let alone IronPython.

this is great, much quicker than using GroupByKey or SortByKey, thanks :slight_smile:

I tried that but considering I have 3 lists that control the order and the thing I’m trying to sort is already a list of lists I don’t know how to actually attach it to make it work.

Hi @PauLtus I tried replicating your original list and use the proposed from @jbo

2 Likes

But If you look back up original comment you can see there’s actually 3 lists of lists between that initial list that are supposed to make up the order, not that first list.

Well guys.
After finding a dumb oversight it works as it should. Thank you all very much!

2 Likes