Custom sort a list of pairs
- To: mathgroup at smc.vnet.net
- Subject: [mg73633] Custom sort a list of pairs
- From: planetmarshalluk at hotmail.com
- Date: Fri, 23 Feb 2007 04:41:55 -0500 (EST)
Hi there,
I've searched through existing posts to no avail, what I want to do is
this:
Sort a nested list of pairs, so that each pair is sorted by reverse
canonical order on its first element, and in normal order on its
second element.
For example, I want some function
sortPairs[items_]
that when given the input
{{ 1,a},{2,a},{3,a},{1,b},{2,b},{1,c}}
produces the output
{{3,a},{2,a},{2,b}{1,a},{1,b},{1,c}}
Any help much appreciated.
Thanks,
Andrew
- Follow-Ups:
- Re: Custom sort a list of pairs
- From: János <janos.lobb@yale.edu>
- Re: Custom sort a list of pairs