Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: sort list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47215] Re: sort list
  • From: Marcus Stollsteimer <marcus314 at yahoo.com>
  • Date: Wed, 31 Mar 2004 02:57:36 -0500 (EST)
  • References: <c4be1n$702$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

  mysort[list_] := list[[Ordering[list[[All, 2]]]]]
or
  mysort[list_] := Sort[list, OrderedQ[{#1[[2]],#2[[2]]}]&]

should do the job:

  In = {{a, 2}, {b, 1}, {c, 3}} // mysort
  Out= {{b, 1}, {a, 2}, {c, 3}}


(You could also look for "Sort" in the online help...)

Regards,
Marcus


Guibout wrote:
> I have a list of the form
> {{something1,x1},{something2,x2},{something3,x3}} where x1,x2, x3
> {{are
> numbers. I want to sort this list with respect to xi.

-- 
Art, all art, is merely an expression of something. -- W. Allen


  • Prev by Date: RE: sort list
  • Next by Date: Re: sort list
  • Previous by thread: RE: sort list
  • Next by thread: Re: sort list