< Back to IRCAM Forum

Sorting a list of lists of xy values according to the first y value of each first list

Hi all,
I would like to know how to sort a list of lists of xy values according to the first y value of each first list.
For example, I have:
((0.0 3.0) (10.0 0.0) (20.0 4.0))
((0.0 10.0) (10.0 3.0) (20.0 4.0))
((0.0 1.0) (10.0 7.0) (20.0 0.0)).
The wanted result should be:
((0.0 1.0) (10.0 7.0) (20.0 0.0))
((0.0 3.0) (10.0 0.0) (20.0 4.0))
((0.0 10.0) (10.0 3.0) (20.0 4.0))
Maybe a loop doesn’t work well in this case, and I guess that a lambda patch could be more useful…
Thanks as usual for your kind attention.
All the best,
Francesco Vitale

Something like that?:

patch:
sort.omp (3.4 KB)

Best
K

Dear Karim,
I’ve just tested your patch – impeccable solution as always. Also thanks for your lighting fast reply in the middle of August!
Best,
Francesco