Re: Sorting 3 points

• To: mathgroup at smc.vnet.net
• Subject: [mg87968] Re: [mg87935] Sorting 3 points
• Date: Mon, 21 Apr 2008 06:37:55 -0400 (EDT)
• References: <200804210721.DAA18821@smc.vnet.net>

```Three possible solutions:

In[1]:= Reverse[SortBy[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, Last]]
Out[1]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}}

In[2]:= SortBy[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, Last[-#1] & ]
Out[2]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}}

In[3]:= Sort[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, #1[[3]] > #2[[3]] & ]
Out[3]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}}

On Mon, Apr 21, 2008 at 9:21 AM, <carlos at colorado.edu> wrote:

> Simple question, but documentation is no help.
> I have three coordinate triplets:
>
>  P1={x1,y1,z1}      P2={x2,y2,z2}      P3={x3,y3,z3}
>
> where all entries are numeric. I wont to sort them into
>
>  P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3}
>
> so that zs3>=zs2>=zs1, with one command
>
>   {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function]
>
> Is that possible and if so, which Ordering Function
> should be used?  Thanks.
>
>

```

• Prev by Date: Re: Sorting 3 points
• Next by Date: Re: Hamiltonian System with NDSolve
• Previous by thread: Sorting 3 points
• Next by thread: Re: Sorting 3 points