Hi,
I have a question about how to sort a matrix for multiple columns. dat<-sample(0:1,1000,replace=T) matrix(dat,ncol=5,nrow=200)->x I want to order like the following: x[order(x[,1],x[,2],x[,3],x[,4],x[,5]),]->x My problem: the number of columns of the matrix to be sorted is variable, in any way I would like to sort for all columns from 1:ncol(x). How to achieve this? Best Maxim [[alternative HTML version deleted]] ______________________________________________ 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.