* list sorting problem
@ 2002-04-11 22:38 Mary Dalrymple
2002-04-11 23:09 ` Vivek Dasmohapatra
0 siblings, 1 reply; 2+ messages in thread
From: Mary Dalrymple @ 2002-04-11 22:38 UTC (permalink / raw)
Can someone help me with the sorting function? I'm getting the following
behavior.
(setq before '(("FEATa" "NP4" "N" . "another comment about np")
("FEATURE" "NP3" "N" . "another comment about np")))
display before:
before's value is
(("FEATa" "NP4" "N" . "another comment about np")
("FEATURE" "NP3" "N" . "another comment about np"))
sort before:
(sort before (lambda (a b) (string< (car a) (car b))))
display before:
before's value is
(("FEATa" "NP4" "N" . "another comment about np"))
One of the list elements disappears. This happens in Emacs 20.7.1. Can
someone tell me what is going on? Thanks --
- Mary Dalrymple
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: list sorting problem
2002-04-11 22:38 list sorting problem Mary Dalrymple
@ 2002-04-11 23:09 ` Vivek Dasmohapatra
0 siblings, 0 replies; 2+ messages in thread
From: Vivek Dasmohapatra @ 2002-04-11 23:09 UTC (permalink / raw)
"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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-11 23:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 22:38 list sorting problem Mary Dalrymple
2002-04-11 23:09 ` Vivek Dasmohapatra
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).