bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list sorting problem


From: Vivek Dasmohapatra
Subject: Re: list sorting problem
Date: 12 Apr 2002 00:09:04 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

"Mary Dalrymple" <dalrymple@parc.xerox.com> writes:

> Can someone help me with the sorting function?  I'm getting the following
> behavior.
[examples deleted]
> One of the list elements disappears.  This happens in Emacs 20.7.1.  Can
> someone tell me what is going on?  Thanks --

M-x describe-function RET sort RET

is your friend:

sort is a built-in function.
(sort LIST PREDICATE)

Sort LIST, stably, comparing elements using PREDICATE.
Returns the sorted list.  LIST is modified by side effects.
PREDICATE is called with two elements of LIST, and should return T
if the first element is "less" than the second.

In other words, sort destructively alters LIST, and returns a sorted list.
LIST is not guaranteed to be useful after you call sort on it. To sort LIST
in place from your programs pov: 

(setq before (sort before (lambda (a b) (string< (car a) (car b)))))

-- 
Just one nuclear family can ruin your whole life.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]