*B = sort(A) sorts the elements along different dimensions of an array, and arranges those elements in ascending order.
*B = sort(A, dim) sorts the elements along the dimension of A specified by a scalar dim.
sort(matrix, dimension) Dimension argument 1 sorts matrix columns. Dimension argument 2 sorts matrix rows
*B = sort(...,mode) sorts the elements in the specified direction, depending on the value of mode.
'ascend' Ascending order (default)
'descend' Descending order
>> A=[7 0 9; 8 2 7; 1 9 7]
A =
7 0 9
8 2 7
1 9 7
*B = sort(A) sorts the elements along different dimensions of an array, and arranges those elements in ascending order.
>> B=sort(A)
B =
1 0 7
7 2 7
8 9 9
*B = sort(A, dim) sorts the elements along the dimension of A specified by a scalar dim.
sort(matrix, dimension) Dimension argument 1 sorts matrix columns. Dimension argument 2 sorts matrix rows
>> B=sort(A,2)
B =
0 7 9
2 7 8
1 7 9
*B = sort(...,mode) sorts the elements in the specified direction, depending on the value of mode.
'ascend' Ascending order (default)
'descend' Descending order
>> V=sort(A,'ascend')
V =
1 0 7
7 2 7
8 9 9
>> V=sort(A,'descend')
V =
8 9 9
7 2 7
1 0 7