MathGroup Archive 2005

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

Search the Archive

Re: Re: Sorting nested list


On May 27, 2005, at 4:56 AM, plizak wrote:

> I have a similar problem, I need to sort the same kind of list
>
> {{a,{2,4,1.,...}}, {c, {1,2,...}},{b,{3.2,-2,. ..}}}
>
> but I need to sort it based on the first element of each subarray,
> while keeping the second element the same.
>
> I did a pretty ugly solution (like 12 lines of code).  Is there a
> quicker more elegant way to sort this?
>

In[9]:=
Sort[lst, #2[[2,1]] >=
     #1[[2,1]] & ]
Out[9]=
{{c, {1, 2}},
   {a, {2, 4, 1.}},
   {b, {3.2, -2}}}

János


  • Prev by Date: Re: restricting range?
  • Next by Date: Re: Printing - mathematica cropping the right hand side... :(
  • Previous by thread: Re: Sorting nested list
  • Next by thread: Re: Sorting nested list