Quantcast
Channel: Cadence Technology Forums
Viewing all articles
Browse latest Browse all 62965

Forum Post: RE: Sorting list by sublist elements

$
0
0
Hi Chris, myList=sort(myList lambda((a b) cadr(a)<cadr(b))) The lambda creates a temporary (nameless) function with two arguments (the two list items to be compared), and then the body of that function is comparing the 2nd element of each sublist (using the cadr). A word of caution: sort is a destructive function (changes the list in place) so make sure you use the return value of the sort function as otherwise slightly odd things can happen. Regards, Andrew.

Viewing all articles
Browse latest Browse all 62965

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>