sort
-
B = sort(A,<dim>,<dir>)sorts the elements of A along dimension dim-
dir sets the sort direction; valid values are
'ascend'or'descend', defaulting to ascending ('ascend') -
dim must be an integer; it defaults to the first non-singleton dimension
-
“Along dimension dim” means (for the ascending case):
-
- Special cases:
- If A is a vector,
sort(A)sorts the elements of the vector - If A is a matrix,
sort(A)treats each column of A as a vector and sorts each column - If A is a matrix,
sort(A,2)sorts the elements of each row
- If A is a vector,