From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Vivek Dasmohapatra Newsgroups: gmane.emacs.bugs Subject: Re: list sorting problem Date: 12 Apr 2002 00:09:04 +0100 Organization: ntl Cablemodem News Service Sender: bug-gnu-emacs-admin@gnu.org Message-ID: <87hemhn88f.fsf@etla.org> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1018566731 27495 127.0.0.1 (11 Apr 2002 23:12:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2002 23:12:11 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16vnje-00079M-00 for ; Fri, 12 Apr 2002 01:12:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16vnjd-0006JR-00; Thu, 11 Apr 2002 19:12:09 -0400 Original-Received: from mailbox1.ucsd.edu ([132.239.1.53]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16vnhO-0006EF-00 for ; Thu, 11 Apr 2002 19:09:52 -0400 Original-Received: from news6-win.server.ntlworld.com (news6d-win.server.ntlworld.com [62.253.162.109]) by mailbox1.ucsd.edu (8.12.1/8.12.1) with ESMTP id g3BN96Eo007146 for ; Thu, 11 Apr 2002 16:09:18 -0700 (PDT) Original-Received: (from news@localhost) by news6-win.server.ntlworld.com (8.8.8+Sun/8.8.8) id AAA05485; Fri, 12 Apr 2002 00:09:04 +0100 (BST) Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: not-for-mail Original-Newsgroups: gnu.emacs.bug Original-Lines: 28 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Original-NNTP-Posting-Host: 80.2.247.20 Original-X-Complaints-To: abuse@ntlworld.com Original-X-Trace: news6-win.server.ntlworld.com 1018566544 80.2.247.20 (Fri, 12 Apr 2002 00:09:04 BST) Original-NNTP-Posting-Date: Fri, 12 Apr 2002 00:09:04 BST Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:589 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:589 "Mary Dalrymple" 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.