RE: Sorting Rows of a Matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg65123] RE: [mg65089] Sorting Rows of a Matrix
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 15 Mar 2006 06:28:45 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Greg,
mat = Table[{Random[Integer, {1, 10}], Random[Integer, {1, 10}]}, {10}]
Sort[mat, Last[#1] < Last[#2] &] // TableForm
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
To: mathgroup at smc.vnet.net
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?
Regards,
Greg