Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Sorting nested lists with strings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116307] Re: Sorting nested lists with strings
  • From: Adriano Pascoletti <adriano.pascoletti at uniud.it>
  • Date: Thu, 10 Feb 2011 05:24:12 -0500 (EST)

Use SortBy[list, f]

In[7]:= list = {{"Paul", 23}, {"Amanda", 55}, {"Carl", 32}}; SortBy[list,
First]
Out[7]= {{"Amanda", 55}, {"Carl", 32}, {"Paul", 23}}


Adriano Pascoletti

2011/2/9 Paperorbifold <kgodelNOSPAM at liberonospam.it>

> I've a nested list of this kind:
> list={{"Paul",23},{"Amanda",55},{"Carl",32},...}
> Suppose I want to perform an alphabetic sort on the first element. Which is
> the condition I've to write in Sort[list,...]?
> Actually Sort[list] automatically operates on the second element.
> Thanks.
>
> --
> ...and I will make them pay for\nwhat they've done! (J.L. Picard)
>
>


  • Prev by Date: Applying function only if the output is positive
  • Next by Date: Bug in ParallelDo?
  • Previous by thread: Re: Sorting nested lists with strings
  • Next by thread: Re: Sorting nested lists with strings