How do you sort 2d points on list?

In my desmos graph Untitled Graph | Desmos all the points are rendered in a pretty random order because I am just generating random numbers. Anyway, what I need to do is sort the list (l_ist) from least to greatest by teh Y values, which I attempted to do for a few hours, reading a few reddit posts and talking to AIs, and I still cannot figure out how to do this, so can someone please help? I would be very grateful. just doing \sort(l_{ist}.y) does not work because it doesn’t rearrange the x in the same way, I also tried to do this by finding permutations, which should work, only if I can figure that out, which I cannot.

Also how do you reverse the order of a list.

I think what you need is simply sort(L, L.y) …
https://www.desmos.com/calculator/4dcorschs2

scroll to the end of the expressions

Second question: sort(L, -L.y)
or more generally sort(L, [L.count … 1])

1 Like

I didn’t even think about sort(L, -L.y)! That’s nice. If you want to reverse a list, rather than your final general solution using sort, you can use the second list to index it:

L_{reverse} = L[L.count...1]
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.