MathGroup Archive 2010

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

Search the Archive

Re: Sorting nested lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108487] Re: Sorting nested lists
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 19 Mar 2010 06:46:38 -0500 (EST)
  • Reply-to: hanlonr at cox.net

Sort[SortBy[data, #[[2]] &]]

or

SortBy[data, {#[[1]], #[[2]]} &]

or

SortBy[data, {First, #[[2]] &}]


Bob Hanlon

---- Canopus56 <canopus56 at yahoo.com> wrote: 

=============
I have a list of x, y, z triples in the form: 
{{350.17,-43.6426,1768. 77},{350.17,-43.5582,1259.67},{350.17,-43.5308,967.89},{350.17,-43.5839,1689.8},{350.17,-43.6445,1753.05},{350.17,-43.6114,2021.65},{350.17,-43.5327,977.36},{350.17,-43.5601,1289.87},{350.17,-43.5858,1720.39},{350.17,-43.6464,1736.25}}
How do I sort a nested list where I want the sort order to be major x-ascending, minor subsort with y-ascending? 
Thanks, Kurt      




  • Prev by Date: Re: need something like ReplaceAllIndexed[]
  • Next by Date: Re: need something like ReplaceAllIndexed[]
  • Previous by thread: Re: Sorting nested lists
  • Next by thread: Re: Sorting nested lists