If Items of list are equal then re-sort list by other function

Dear dynamo users, it’s been troubling me all day. I have a list of points. I want to sort them by the value of their X coordinate. If their x value is equal I want to sort them by their distance to another point. I really don’t know how to handle that.

X values equal to what?

equal to one another. Sorry I should have specified that.

If they are the same to be more accurate

Yes please and show complete graph with all the previews visible.

Similar topic discussed here:

1 Like

I still have a basic question. How can I compare items of the same list? How do I say if items of list are the same get index of items? I simply cannot figure that out.

Try a List.GroupByKey node. Then get the distance from each sublist of points to the ‘point of interest’, and sort the sublists using a List.SortByKey (all inputs should be @L2).

Thank you very much for the response. What would the key be in the case of the same items in list?

Build the graph. By using a group by key node first you have sublists which contain only matching values. You might want to add a List.SortByKey node first (thought you had that much.

Also, don’t spend the ram sorting by index by value. The values will sort themselves out just fine.

PS: no need to multi-post in 3 threads for the same problem. Just makes more convoluted conversations. Let’s leave all posts on this in this topic.

I tried to split the problem in order to get more specific answers. Unfortunately, i still haven’t understood the input for the Keys in order to group separately the same items.

What have you tried?