Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re:Sorting and Selecting in Multilevel Lists

  • To: mathgroup at
  • Subject: [mg31179] Re:Sorting and Selecting in Multilevel Lists
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Tue, 16 Oct 2001 01:18:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

aes wanted to sort a list of ordered pairs according to the magnitude of
The following works well. 

  Sort[data, First[#1]^2+Last[#1]^2<First[#2]^2+Last[#2]^2& ]


Here First[] is the x value, and Last[] is the y value.
A general tip;  First[expr] is slightly faster than Part[expr,1].  Also
Last[expr] should be faster than anything else that does the same thing.

Ted Ersek

Check Mathematica Tips, Tricks at

  • Prev by Date: Re: Plot-Function
  • Next by Date: Re: Plot-Function
  • Previous by thread: Two-dimensional input
  • Next by thread: Parallel Processing