Sort sublists

Hi, I have a problem with sorting. I’ve divided points list to sublists by X and now I would like to sort all the points with same X by Y (and want to join them by line, so I need it to be in order).

All I can do is take one sublist at a time (python script just create a list from one sublist), then everything works like I want it to.

How would you solve this task?

Hi @dariusz.mordal,

You can use the node List.GroupByKey with the Points as List and their X-value (maybe do math.round) as Keys, this way each point is now grouped with other points with the same X-value, then you can sort those sublists by their Y-value, like this:


Ps: the list level (@L2) in the Sort.ByFunction node tells that node to do that function in the list of level 2, the lists which contain the individual points.

2021-01-03 SortPointsByXThenY.dyn (17.1 KB)

And check your results, you might need to do some rounding on the X or Y values from the points to Group them together.

1 Like