< Back to IRCAM Forum

Sorting lists by the nth element

Hello,

I need to sort a list of lists by the nth element of the sub-lists.
e.g.
( (1 5 10) (2 3 20) (3 2 30) )
sort by the second element
-> ( (3 2 30) (2 3 20) (1 5 10) )

“sort” and “sort.” look like working with lists, but not with list of lists, right?

Thanks,

Marco

Dear Marco,

Use the “key” and enjoy the sort.!!

Gruesse,

Marco

sort.png

Thanks!

Marco