MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sort problem


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
>


  • Prev by Date: Re: Other bug in ContourPlot
  • Next by Date: Re: Simplifying Log[a] + Log[expr_] - Log[2 expr_]: Brute force necessary?
  • Previous by thread: Sort problem
  • Next by thread: Re: Sort problem