MATLAB: Sorting 2D matrix

sort

Hello all,
I'm troubling with sorting of the matrix. I have a matrix
A = 6.0000 18.0000 20.0000 23.0000 26.0000
3.1464 1.4302 2.9512 0.9988 2.7403
I need to sort the second row in ascending order. Simultaneously the first row also needs to be sorted according to the second row like
required matrix = 23.0000 18.0000 26.0000 20.0000 6.0000
0.9988 1.4302 2.7403 2.9512 3.1464
when I trying to use the sort command like sort(A,2), I'm getting
sort(A,2)=
6.0000 18.0000 20.0000 23.0000 26.0000
0.9988 1.4302 2.7403 2.9512 3.1464
Can you help me here. Thank you.

Best Answer

>> sortrows(A.',2).'
ans =
23.0000 18.0000 26.0000 20.0000 6.0000
0.9988 1.4302 2.7403 2.9512 3.1464
>>