Re: how to perform a multi-column sort
- From: Zach Beane <xach@xxxxxxxx>
- Date: Fri, 29 Apr 2011 05:52:18 -0400
jimka <jimka@xxxxxxxxx> writes:
What I'd like to write is the following:
(mulit-sort some-list
;; -key- -equal- -lessp-
#'car #'= #'<
#'cadr #'string-equal #'string-lessp
(compose #'accessor42 #'caddr) #'equal42 #'cmp42)
However, even this seems redundant. I.e., maybe there is a cleverer
predicate possible where I would not have to supply the equal/lessp
pairs, but rather just the lessp functions.
I wrote an implementation of the idea here:
http://groups.google.com/group/comp.lang.lisp/msg/a14dcbfcf6cccd13
It may be possible to
calculate the equivalence function with something like
(lambda (a b) (and (not (lessp b a)) (not (lessp a b))))
However, certainly calling this is slower than simply calling #'=.
That's what SORT itself does, though, so I don't think it's a big deal.
Zach
.
- References:
- how to perform a multi-column sort
- From: jimka
- how to perform a multi-column sort
- Prev by Date: Re: The pervasiveness of DEFVAR and the Lisp curse
- Next by Date: Re: The pervasiveness of DEFVAR and the Lisp curse
- Previous by thread: Re: how to perform a multi-column sort
- Index(es):
Relevant Pages
|