# Sort groups by sorted keys

Hi, i am a beginner on dynamo and would like to know how i can use a sorted list to sort another one… !

List.SortByKey

Sorting a list by a key… And please use screenshots not potato-phone-pictures… It physically hurts the eyes

4 Likes

Iam really sorry for the bad pic

Sorry but list. Sortbykey doesn’t seem to work…

Hi,

Alternatively you can (instead of grouping and sorting separately (it works either way)) use the Orchid node…

But as you’re working with lists-within-lists-within-lists… you NEED to use list levels a lot.

1 Like

Unfortunately i can’t get what i want , even when playing with the levels…

Any idea of a solution ?

Don’t know what to tell ya… Not without your dateset anyway…

Thanks for the test but even in yours, the result at the end is not the one expected:
elements in your watch node are in the wrong order , the right result should have been:
element1,element2,element3,e4 and ,e5,e6,e7…
e1, e3, e2, e4 & e7,e6,e5…
Sorry

Why so ? The elements are sorted in a way that the orders are sorted.

1 Like

No… They are exactly as expected… the order is sorted from assumed to be unsorted in the beginning… and elements taking the places corresponding to the sorting of the corrected order…

So the final order is exactly as one would expect…

1 Like

A colleague of mine created a node for this: (RHA_Utilities package, credit:Rami Hamati)

But my goal is not achieved, maybe i havent very well explained what i aim for.

My Goal is to obtain the list 1 in the order of the list 2. Maybe because as a grasshopper user my logic is different but i don’t understand why in every solution you purpose i never get what i want … !!!

Do you want to do something like this ? If it is only sorting your rooms another way…

@mellouze

Thanks for your comment, but as you can see the number of the rooms are now completely diffrent from the initial list. It has taken only one item of the right “Level” and repeated it …Nice try but this is still not the expected result !

Use List.UniqueItems on your keys and use List.AllIndexOf instead. It should work if you tweak a little bit your graph.

Try things on your own and experiment with Dynamo. Only that why you’ll progress

Have you tried SortByFunction? I know it is in 2.0, not sure about earlier Dynamo versions.

Hi @kennyb6

You could also use @ListLevel to avoid List.Sort node:

3 Likes

@rbrision

You can try something like this!!!

Mitesh