MathGroup Archive 2004

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

Search the Archive

Re: Sorting a list of pairs on the second elements


János <janos.lobb at yale.edu> wrote in message news:<cklmi7$f1o$1 at smc.vnet.net>...
> [...]
> In general, if I have a list whose elements are m-member lists, like  
> {{a1,...,am},...,{z1,...,zm}}, then my question is what is the  
> best/fastest way to sort it on the k-th elements of the members where  
> 1<=k<=m and ak,...,zk are arbitrary objects - in my case Strings - and  
> use as little memory for it as possible.
> 

  Sort[list, OrderedQ[{#1[[k]],#2[[k]]}]& ]

works for me with your data.


  • Prev by Date: Re: Need to calculate Nyquist frequency from data
  • Next by Date: Re: Outer product in mathematica
  • Previous by thread: Sorting a list of pairs on the second elements
  • Next by thread: Re: Sorting a list of pairs on the second elements