Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Sorting nested list

  • To: mathgroup at
  • Subject: [mg57344] Re: Sorting nested list
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Wed, 25 May 2005 06:02:51 -0400 (EDT)
  • Organization: New York University
  • References: <d6us0f$ivm$>
  • Reply-to: jmg336 at
  • Sender: owner-wri-mathgroup at

Hi Gernot,

I think the following method using Map and anonymous functions should do 
the work:




Basically, the above expression tells Mathematica to go through the list 
called "data" element by element, that is pair by pair in this case, and 
to apply the anonymous function {#[[1]],Sort[#[[2]]]}& on each of them.
This function creates a new pair where the first element #[[1]] is not 
changed and the second #[[2]] is sorted with the default option of the 
command Sort.

Best regards,

Gernot Pfanner wrote:
> 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: Sorting nested list
  • Next by Date: Re: Log function
  • Previous by thread: Re: Sorting nested list
  • Next by thread: Re: Sorting nested list