MATLAB: How to sort or rearrange a column with respect to the other column?!

arrangecolumnMATLABsort

Hello Everybody;
wish you are all doing well;
if i have a data of two columns and i want to sort one of the columns in a descending order and also keep the other column fixed and likened with the changed one, how can i do that?! assuming that column 1 is the ID of column two
sample data:
241 5
1245 4
684 4
806 4
674 3
Appreciating your help ;

Best Answer

Use sortrows function. For example
A=[241 5;1245 4;684 4;806 4;674 3]
B=sortrows(A,2)
% Or by descending order
B=sortrows(A,-2)