I would like to sort a matrix according to a particular column. There is a sort function, but it sorts all columns independently.
sort
For example, if my mat
An alternative to sortrows(), which can be applied to broader scenarios.
sortrows()
save the sorting indices of the row/column you want to order by:
[~,idx]=sort(data(:,1));
reorder all the rows/columns according to the previous sorted indices
data=data(idx,:)