Re: Sorting Rows of a Matrix

*To*: mathgroup at smc.vnet.net*Subject*: [mg65122] Re: [mg65089] Sorting Rows of a Matrix*From*: Gregory Lypny <gregory.lypny at videotron.ca>*Date*: Wed, 15 Mar 2006 06:28:42 -0500 (EST)*References*: <20060314130602.JZDI9108.eastrmmtao06.cox.net@[172.18.52.8]>*Sender*: owner-wri-mathgroup at wolfram.com

Works like a charm. Now what if that second column contained strings rather than numbers, for example, "Sydney", "Martha", "Alberta", and "Ralph"? Regards, Greg On Tue, Mar 14, 2006, at 8:05 AM, Bob Hanlon wrote: > Sort[data, #1[[2]] < #2[[2]] &] > > > Bob Hanlon > >> >> From: Gregory Lypny <gregory.lypny at videotron.ca> To: mathgroup at smc.vnet.net >> Subject: [mg65122] [mg65089] Sorting Rows of a Matrix >> >> 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 >> >>