mat<-matrix(data = as.integer(runif(16, 1, 20)), nrow = 4)
#Sort the matrix in respect to the second column of mat
m<-mat.sort(mat, 2)
#Sorting mat according to more than one column
mat<-matrix(data = c(rep(3, 3), as.integer(runif(13, 1, 20))), nrow = 4)
m1<-mat.sort(mat, c(1, 2))
m2<-mat.sort(mat, c(2, 1))
Run the code above in your browser using DataLab