MathGroup Archive 2006

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

Search the Archive

RE: Sorting Rows of a Matrix


mat = Table[{Random[Integer, {1, 10}], Random[Integer, {1, 10}]}, {10}]

Sort[mat, Last[#1] < Last[#2] &] // TableForm

David Park
djmp at 

From: Gregory Lypny [mailto:gregory.lypny at]
To: mathgroup at

Hello everyone,

How can I sort the rows of a matrix by using one or more of the  
columns as sort keys just like in a spreadsheet?  For example, if  
matrix M is 12 x 2 with numbers in the first column and unordered  
month numbers in the second, how would I order the rows by month?



  • Prev by Date: Re: Graphics3D polygon face colors
  • Next by Date: Re: Writing regular text?
  • Previous by thread: Re: Sorting Rows of a Matrix
  • Next by thread: Re: Sorting Rows of a Matrix