MathGroup Archive 2005

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

Search the Archive

Re: Sort problem


age={30,12,60,20};
pple={"john","kate","peter","alice"};

{age,pple}=Transpose[Sort[Thread[{age,pple}]]]

{{12, 20, 30, 60}, {"kate", "alice", "john", "peter"}}

or

age={30,12,60,20};
pple={"john","kate","peter","alice"};

pple=pple[[Ordering[age]]]

{kate,alice,john,peter}

age=Sort[age]

{12,20,30,60}


Bob Hanlon

> 
> From: konstantpi at mail15.com
To: mathgroup at smc.vnet.net
> Date: 2005/04/21 Thu AM 05:36:11 EDT
> To: mathgroup at smc.vnet.net
> Subject: [mg56316] [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
> 
> 


  • Prev by Date: Re: removing sublist . Again and Different
  • Next by Date: Re: removing sublist . Again and Different
  • Previous by thread: Re: Sort problem
  • Next by thread: Re: Sort problem