From: Martin Haslinger
Subject: Sort function
Date: 
Message-ID: <8qq76p$2gab$1@wrath.news.nacamar.de>
hi all,

I'm sorry about by english but I'm searching a small sort-function to sort
such list-entries:
a List consits of 3-value-lists:
((1 1 3) (2 1 3) (1 2 3) (3 1 3) (1 3 3) (3 2 3) (3 3 3) (4 1 3) (1 4 3)))

output when sorted by the first value:
((1 1 3) (1 2 3) (1 3 3) (1 4 3) (2 1 3) (3 1 3) (3 2 3) (3 3 3) (4 1 3))

-> sortet by eg. the first (second etc.) value from the list in the list.

From: Wolfhard Buß
Subject: Re: Sort function
Date: 
Message-ID: <m31yy7dtmg.fsf@minka.katzen.ol>
"Martin Haslinger" <···@ferroglas.co.at> writes:

> hi all,
> 
> I'm sorry about by english but I'm searching a small sort-function to sort
> such list-entries:

look at

http://www.xanalys.com/software_tools/reference/HyperSpec/Body/fun_finish-ou_clear-output.html

-wb
From: Wolfhard Buß
Subject: Re: Sort function
Date: 
Message-ID: <m3lmwfdmce.fsf@minka.katzen.ol>
Sorry for the wrong link. :(
Look at

http://www.xanalys.com/software_tools/reference/HyperSpec/Body/fun_sortcm_stable-sort.html

-wb
From: Barry Margolin
Subject: Re: Sort function
Date: 
Message-ID: <vc2A5.4$aT.436@burlma1-snr2>
In article <·············@wrath.news.nacamar.de>,
Martin Haslinger <···@ferroglas.co.at> wrote:
>hi all,
>
>I'm sorry about by english but I'm searching a small sort-function to sort
>such list-entries:
>a List consits of 3-value-lists:
>((1 1 3) (2 1 3) (1 2 3) (3 1 3) (1 3 3) (3 2 3) (3 3 3) (4 1 3) (1 4 3)))
>
>output when sorted by the first value:
>((1 1 3) (1 2 3) (1 3 3) (1 4 3) (2 1 3) (3 1 3) (3 2 3) (3 3 3) (4 1 3))
>
>-> sortet by eg. the first (second etc.) value from the list in the list.

What's wrong with Common Lisp's built-in SORT function?  You supply a
function that compares two elements, and it then sorts the list using that
function.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Marco Antoniotti
Subject: Re: Sort function
Date: 
Message-ID: <y6czokvut9n.fsf@octagon.mrl.nyu.edu>
"Martin Haslinger" <···@ferroglas.co.at> writes:

> hi all,
> 
> I'm sorry about by english but I'm searching a small sort-function to sort
> such list-entries:
> a List consits of 3-value-lists:
> ((1 1 3) (2 1 3) (1 2 3) (3 1 3) (1 3 3) (3 2 3) (3 3 3) (4 1 3) (1 4 3)))
> 
> output when sorted by the first value:
> ((1 1 3) (1 2 3) (1 3 3) (1 4 3) (2 1 3) (3 1 3) (3 2 3) (3 3 3) (4 1 3))
> 
> -> sortet by eg. the first (second etc.) value from the list in the list.

The function is called SORT (or STABLE-SORT).

* (defvar *the-list* '((1 1 3) (2 1 3) (1 2 3) (3 1 3) (1 3 3) (3 2 3) (3 3 3) (4 1 3) (1 4 3)))
*THE-LIST*

* *the-list*
((1 1 3) (2 1 3) (1 2 3) (3 1 3) (1 3 3) (3 2 3) (3 3 3) (4 1 3) (1 4 3))

* (sort *the-list* (function <) :key (function first))
((1 1 3) (1 2 3) (1 3 3) (1 4 3) (2 1 3) (3 1 3) (3 2 3) (3 3 3) (4 1 3))

* (sort *the-list* (function <) :key (function second))
((1 1 3) (2 1 3) (3 1 3) (4 1 3) (1 2 3) (3 2 3) (1 3 3) (3 3 3) (1 4 3))

* 

Cheers


-- 
Marco Antoniotti =============================================================
NYU Bioinformatics Group			 tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                          fax  +1 - 212 - 995 4122
New York, NY 10003, USA				 http://galt.mrl.nyu.edu/valis
             Like DNA, such a language [Lisp] does not go out of style.
			      Paul Graham, ANSI Common Lisp