Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1993
*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 1993

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

Search the Archive

Re: sort pairs

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: sort pairs
  • From: keiper
  • Date: Thu, 11 Nov 93 07:01:32 -0600

	> How can I sort pairs of values -- basing the sort on the
	> first value and then break ties on the second value in
	> the pair.

Just use Sort[ ].  That is what it does.  For example:

In[5]:= data = Flatten[Table[{j, 4-i}, {i, 3}, {j, 3}], 1]

Out[5]= {{1, 3}, {2, 3}, {3, 3}, {1, 2}, {2, 2}, {3, 2}, {1, 1}, {2, 1}, 
 
>    {3, 1}}

In[6]:= Sort[%]

Out[6]= {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, 
 
>    {3, 3}}


Jerry B. Keiper
keiper at wri.com
Wolfram Research, Inc.






  • Prev by Date: notation
  • Next by Date: courses
  • Previous by thread: notation
  • Next by thread: sort pairs