       Re: Sort problem

• To: mathgroup at smc.vnet.net
• Subject: [mg81743] Re: Sort problem
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Tue, 2 Oct 2007 05:49:03 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <fdqd33\$n6m\$1@smc.vnet.net>

```Donald DuBois wrote:
> Hello,
>
> This Sort works
>
> In:= Sort[{r, a, x}]
>
> Out= {a, r, x}
>
> but this one doesn't:
>
> In:= Sort[{{r, 2}, {a, 3}, {x, 4}}, #1[] < #2[] &]
>
> Out= {{r, 2}, {a, 3}, {x, 4}}
>
>
> What am I doing wrong?

Using inequalities on purely alphabetic symbol. Use either nothing (as
long as you want the list sorted according to its first column) or
*OrderedQ* as in the following examples.

In:= Sort[{{r, 2}, {a, 3}, {x, 4}}]

Out= {{a, 3}, {r, 2}, {x, 4}}

In:= Sort[{{r, 2}, {a, 3}, {x, 4}}, OrderedQ[{#1[], #2[]}] &]

Out= {{a, 3}, {r, 2}, {x, 4}}

Regards,
--
Jean-Marc

```

• Prev by Date: Re: Equivalent functionality to colorbar in Mathematica?
• Next by Date: Re: Sort problem
• Previous by thread: Re: Sort problem
• Next by thread: Re: Sort problem