# How to sort a list based on 2 different list comparison?

1st consists a list of curves.
2nd consists list of a point on each curve from the 1st list
3rd are sorted points equal from the 2nd list of points but from another curve.
How to sort the 1st list based on the points of the 3rd list?

Points themselves arenâ€™t sortable - you need to have sortable or quantifiable geometry to achieve that.

So, think about what would you want to sort by.

• The X value?
• The Y value?
• A combination of X and Y values (remapping ranges for X to 1â€¦10 and Y to 0.10â€¦0.01 and adding them together can help there)?
• The distance from the origin?
• The distance from a larger geometry?
• Something completely different?

Once you have that quantifiable value from the 3rd list, you can use a List.SortByKey node to sort the first list of curves according to the values produced.

1 Like

maybe this can help:

@JHJHJHJH

I donâ€™t want them to be sorted by default. The result I was hoping from the first list should be according to the order of the third list, which is 0,5,4,3,2,1 of their index. But i is not always in that order since I have other set of line/curves with a diffirent order of points and numbers that has random order

use the nod â€śList.FirstIndexOfâ€ť to retrieve the index of the 3rd list in the 2nd

You might test existence of each point on list of curves by (parameter at point) node, you will get nulls and one real value with the required index .

Weâ€™ll need the full graph and the data set to help here then, as we havenâ€™t been given enough info to know the order the points were generated in.

I managed to find it on this forum, just use IndexOf and List.Map. I should have search through the forums first.

Glad to hear. Can you post that portion of the graph so others can learn from this post?

1 Like