Re: Sorting 3 points
- To: mathgroup at smc.vnet.net
- Subject: [mg87984] Re: Sorting 3 points
- From: Alexey Popkov <popkov at gmail.com>
- Date: Mon, 21 Apr 2008 06:50:41 -0400 (EDT)
- References: <fuhfa6$ibk$1@smc.vnet.net>
On 21 =C1=D0=D2, 11:21, car... at colorado.edu wrote: > Simple question, but documentation is no help. > I have three coordinate triplets: > > =9AP1={x1,y1,z1} =9A =9A =9AP2={x2,y2,z2} =9A =9A =9AP3={x3,y3,z3} > > where all entries are numeric. I wont to sort them into > > =9AP1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} > > so that zs3>=zs2>=zs1, with one command > > =9A =9A{P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] > > Is that possible and if so, which Ordering Function > should be used? =9AThanks. The simplest solution is to use SortBy {P1s,P2s,P3s}=SortBy[{P1,P2,P3},#[[3]]&] or {P1s,P2s,P3s}=SortBy[{P1,P2,P3},Last]