MathGroup Archive 2005

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

Search the Archive

Re: Sorting nested list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57363] Re: [mg57295] Sorting nested list
  • From: "Tomas Garza Hernandez" <tgarza10 at msn.com>
  • Date: Wed, 25 May 2005 06:03:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

One possibility:

In[1]:=
ex={{a,Table[Random[Integer,{0,9}],{5}]},{b,
      
Table[Random[Integer,{0,9}],{5}]},{c,Table[Random[Integer,{0,9}],{5}]}}

Out[1]=
{{a,{5,3,3,6,0}},{b,{1,4,8,2,2}},{c,{0,0,6,5,5}}}

In[2]:=
Transpose[{#[[1]]&/@ex,Sort/@(#[[2]]&/@ex)}]

Out[2]=
{{a,{0,3,3,5,6}},{b,{1,2,2,4,8}},{c,{0,0,5,5,6}}}

Tomas Garza
Mexico City

>From: Gernot Pfanner <pfannerg at stud.uni-graz.at>
To: mathgroup at smc.vnet.net
>Subject: [mg57363] [mg57295] Sorting nested list
>Date: Tue, 24 May 2005 05:12:32 -0400 (EDT)
>
>Hi!
>
>Please forgive me, if this is the 100.000th posting concerning sorting a
>list. But at the moment I'm pretty confused, and so I ask you kindly for
>your help...
>Given something like
>{{a,{2,4,1.,...}},{b,{3.2,-2,...}}}
>How do I sort just the inner lists (i.e. e.g. {2,4,1.,...}), so that my
>object finally looks like
>{{a,{1.,2,4.,...}},{b,{-2,3.2,...}}}
>In this spirit
>With thanks in advance
>Yours Gernot
>



  • Prev by Date: Re: MathLink and GUIKit
  • Next by Date: Re: Sorting nested list
  • Previous by thread: Re: Sorting nested list
  • Next by thread: Re: Sorting nested list