Sorting element list by an already sorted list

Hi,
I am trying to sort a list of elements ids by the element location. I have a list of sorted geometry locations and wish to map this order onto the original list of elements but am struggling to find a way to do this.

I’d recommend looking into SortByKey and sorting by multiple parameters/values in series. There are many examples on the forum the go into detail. SortByFunction requires you to provide a function and would still require you to maintain the original sorted structure anyway.

Basically, you want to sort and group by one metric and then sort the sublists (groups) by the second metric so that the original sorting isn’t lost. Then you can always flatten your final list.