Newsgroups: comp.lang.lisp
From: Zach Beane <x...@xach.com>
Date: Mon, 20 Aug 2007 14:06:59 -0400
Local: Mon, Aug 20 2007 2:06 pm
Subject: Re: Sorting by enumeration
[snip]
> I also have lists of doubletons (currently represented as cons cells) I was drawing a blank, too, until I read this section of the SORT > with one number and one letter each. Like so: > (setf values '((3 . F) (4 . C) (2 . A) (6 . C) (7 . E))) > I want to be able to 1) sort by number, 2) sort by letter, 3) sort by page: The predicate is assumed to consider two elements x and y to be (BTW, this is one of the reasons I think it's valuable to learn how to With that hint, I came up with this: (defparameter *conses* (defun sort-fun (test key) (defun cascaded-predicate (&rest funs) (defun cascade-sort (sequence &rest tests-and-keys) #| (cascade-sort (copy-tree *conses*) #'< #'car) (cascade-sort (copy-tree *conses*) #'< #'car #'< #'cdr) => (cascade-sort (copy-tree *conses*) #'< #'car #'> #'cdr) => (cascade-sort (copy-tree *conses*) #'> #'car #'> #'cdr) => (cascade-sort (copy-tree *conses*) #'> #'car #'< #'cdr) => (cascade-sort (copy-tree *conses*) #'< #'cdr #'< #'car) => (cascade-sort (copy-tree *conses*) #'< #'cdr #'> #'car) => |# Tweaking this to work with your original example should, I hope, be Zach You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||