Re: Sort problem
- To: mathgroup at smc.vnet.net
- Subject: [mg56333] Re: [mg56292] Sort problem
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Fri, 22 Apr 2005 06:23:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: konstantpi at mail15.com [mailto:konstantpi at mail15.com] To: mathgroup at smc.vnet.net >Sent: Thursday, April 21, 2005 11:36 AM >Subject: [mg56333] [mg56292] Sort problem > >Hi >How to sort two lists such as: >age={30,12,60,20}; >pple={"john","kate","peter","alice"}; > >to give the output: >age={12,20,30,60} >pple={"kate","alice","john","peter"} > >ie: to keep every person opposite his age number. >thanks > > In[7]:= {sage, spple} = With[{ordage = Ordering[age]}, {age[[ordage]], pple[[ordage]]}] Out[7]= {{12, 20, 30, 60}, {"kate", "alice", "john", "peter"}} -- Hartmut Wolf