Sorting points to match another point list

I currently have two lists with almost similar point coordiantes, but with different orders. I want to get both list in the same order, but one order is fixed. So I’m looking for a function to give me the index of the similar point in the other list, so I can oder them this way.
I hope I could describe my problem well.

Hi @klara.steinMZ7FJ ,

You can use the node List.IndexOf to get the first matching index.
List.AllIndicesOf returns all indices, but I don’t think you’ll need that one here.

Thank you, but I already tried that and I think it is not working, because the points aren’t exactly the same. I think I need to combine the IndexOf and ClosestPointTo function in some way, but I don’t know how.

Okay that changes the question a little bit. Then I would recommend using the node Geometry.DistanceTo, see this example below which I created yesterday for someone else, I think this solution applies for you aswell:

@klara.steinMZ7FJ can you try this? Creating bounding boxes instead of geometry would be beneficial in terms of performance when you have thousands of points.

If you have a known level of tolerance it would be easier to rebuild all your points to that tolerance and then compare. When comparing point or curve geometry like this it’s also best to compare strings rather than the actual geometry objects, as the stored values may not be exactly the same even if they appear to match.