MATLAB: Elements relation on a matrice? Basic

matricerelation

Hello,
Is it possible to relate elements on a matrice? For exemple:
A = [20 1; 180 2; 135 3; 80 4]
If I want to sort the elements from the first collumn without changing its second collumn corresponding, is it possible?
I want it to end like:
B = [20 1; 80 4; 135 3; 180 2]
Thanks

Best Answer

  • doc sortrows
    for this case
    sortrows(A,[1 2])