Re: Sort problem
- To: mathgroup at smc.vnet.net
- Subject: [mg81692] Re: [mg81678] Sort problem
- From: Adriano Pascoletti <adriano.pascoletti at dimi.uniud.it>
- Date: Tue, 2 Oct 2007 05:22:40 -0400 (EDT)
- References: <200710010849.EAA23017@smc.vnet.net>
Don, use the canonical order. From the help of Sort: "Sort[list,p] applies the function p to pairs of elements in list to determine whether they are in order. The default function p is OrderedQ[{#1,#2}]&". In[8]:= Sort[{{r, 2}, {a, 3}, {x, 4}}, OrderedQ[{#1[[1]], #2[[1]]}] & ] Out[8]= {{a, 3}, {r, 2}, {x, 4}} Adriano Pascoletti On 1 ott 2007, at 10:49, Donald DuBois wrote: > Hello, > > This Sort works > > In[32]:= Sort[{r, a, x}] > > Out[32]= {a, r, x} > > but this one doesn't: > > In[33]:= Sort[{{r, 2}, {a, 3}, {x, 4}}, #1[[1]] < #2[[1]] &] > > Out[33]= {{r, 2}, {a, 3}, {x, 4}} > > > What am I doing wrong? > > Don >
- References:
- Sort problem
- From: Donald DuBois <donabc@comcast.net>
- Sort problem