Re: how to perform a multi-column sort

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:

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.


Relevant Pages