Here's an example.  See ?order

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

Best,
Erik Iverson

ermimi wrote:
> 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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to