MATLAB: Sorting matrix

matrix

I have amatrix
A=[1 2 13;
10 1 2;
8 14 3]
I want to sort 2nd column,so the corresponding values must also change
as
A=[10 1 2;
1 2 13;
8 14 3]

Best Answer

[~,indices] = sort(A(:,2));
A = A(indices,:);