[racket] [racket-dev] Feature request: multiple keys in sort

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Jun 10 16:55:28 EDT 2012

Please reply to the list. 





On Jun 10, 2012, at 4:50 PM, Harry Spier wrote:

> Thanks Matthias,
> 
> What I meant was something like this:
> (sort '((9 9 9) (8 8 8) (8 9 8) (7 7 7) (7 9 7)) (> #:key first) (>
> #key second))
>> '((9 9 9) (8 9 8) (8 8 8) (7 9 7) (7 7 7))
> 
> Also I'm not a member of the dev list (I thought my subscriptiion went
> through but apparently it didn't) so if you could forward this, I'd
> appreciate it).
> 
> Harry Spier
> 
> On Sun, Jun 10, 2012 at 4:39 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>> 
>> 
>> On Jun 9, 2012, at 10:56 AM, Harry Spier wrote:
>> 
>>> Would it be possible to extend the sort function to allow for multiple
>>> keys to facilitate sorting lists of lists or lists of structs.
>> 
>> 
>> It is possible to sort lists of lists and lists of structs:
>> Welcome to DrRacket, version 5.3.0.10--2012-06-09(6b2419f1/d) [3m].
>> Language: racket.
>>> (sort '((1 0 2) (9 7 8) (6 2 5)) > #:key second)
>> '((9 7 8) (6 2 5) (1 0 2))
>> 
>> ;; ---
>> 
>> Do you want to supply multiple comparisons for multiple keys?
>> 


Posted on the users mailing list.