# How do you sort 2d points on list?

**URL:** <https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405>\
**Category:** Questions\
**Created:** [November 23, 2025, 4:03pm UTC](https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405 "2025-11-23T16:03:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![desmosguy](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/desmosguy/32/9135_2.png) [@desmosguy](https://cl.desmos.com/u/desmosguy)\
**Post date:** [November 23, 2025, 4:03pm UTC](https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405/1 "2025-11-23T16:03:49Z")

</div>

In my desmos graph [Untitled Graph | Desmos](https://www.desmos.com/calculator/htvqpfq47z) 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.

---

<div class="post-metadata">

**Author:** ![Guzman\_Tierno](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/guzman_tierno/32/6149_2.png) [@Guzman\_Tierno](https://cl.desmos.com/u/Guzman_Tierno)\
**Post date:** [November 23, 2025, 6:15pm UTC](https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405/2 "2025-11-23T18:15:55Z")

</div>

I think what you need is simply sort(L, L.y) …  
[https://www.desmos.com/calculator/4dcorschs2](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])

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [November 23, 2025, 10:51pm UTC](https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405/3 "2025-11-23T22:51:01Z")

</div>

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:

```auto
L_{reverse} = L[L.count...1]

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/f/f5bd144684474e9a2f333002cde9840e52c5dbd3.png) [@system](https://cl.desmos.com/u/system)\
**Post date:** [November 25, 2025, 10:51pm UTC](https://cl.desmos.com/t/how-do-you-sort-2d-points-on-list/8405/4 "2025-11-25T22:51:05Z")

</div>

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