sort
Sort array elements
Description
sorts the elements
of B
= sort(A
)A
. By default, sort
uses ascending sorted
order.
If
A
is a vector, thensort(A)
sorts the vector elements.If
A
is a matrix, thensort(A)
treats the columns ofA
as vectors and sorts each column.If
A
is a multidimensional array, thensort(A)
operates along the first array dimension whose size does not equal 1, treating the elements as vectors.
specifies
additional parameters for sorting. For example, B
= sort(___,Name,Value
)sort(A,'ComparisonMethod','abs')
sorts
the elements of A
by magnitude.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
More About
Tips
The
sortrows
function provides additional flexibility for subsorting over multiple columns of matrix or table inputs.The
sort
function and the relational operators use different orderings for complex numbers. For more information, see Relational Operations.
Extended Capabilities
Version History
Introduced before R2006a