MathGroup Archive 2005

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

Search the Archive

Re: Sort problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56357] Re: Sort problem
  • From: Harald Giese <spam.delete at gmx.net>
  • Date: Fri, 22 Apr 2005 06:24:16 -0400 (EDT)
  • References: <d47suf$54n$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

konstantpi at mail15.com wrote:
> 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
> 

Hi Konstantin,

try "Ordering":

ord=Ordering[age]
{2,4,1,3}

age[[ord]]
(* same as: Sort[age] *)
{12,20,30,60}

(* but can be used to re-order "pple" *)
pple[[ord]]
{kate,alice,john,peter}


HTH
Harald
from Hamburg@Germany


  • Prev by Date: Re: multiple 3d plots
  • Next by Date: Re: Sort problem
  • Previous by thread: Re: Sort problem
  • Next by thread: Re: Sort problem