Skip to content

SORT MATRIX

3 messages · ermimi, Erik Iverson, Gábor Csárdi

#
I have a matrix with 2 columns and n row. I need sort the matrix by the first
column but the second row must be sort in the same order that the first
column. Somebody know how I can sort this matrix.
Thanks very much
#
Here's an example.  See ?order


mt <- matrix(sample(1:20), ncol = 2)
mt[order(mt[,1]),]

Best,
Erik Iverson
ermimi wrote:
#
M[ order(M[,1]), ]

G.
On Mon, Mar 10, 2008 at 01:56:45PM -0700, ermimi wrote: