powered by
This function can use the sort.list function in R. The reason for using it is that one wants the sort to carry along all columns.
sort_matrix(x, j)
A sorted matrix
An input matrix with several columns
The column number with reference to which one wants to sort
set.seed(30) x=matrix(sample(1:50),ncol=5) y=sort_matrix(x,3);y
Run the code above in your browser using DataLab