sort
Sort elements of symbolic arrays
Description
sorts
the elements of Y = sort(X)X in the default ascending order.
If
Xis a vector, thensort(X)sorts the vector elements ofX.If
Xis a matrix, thensort(X)treats the columns ofXas vectors and sorts each column independently.If
Xis a multidimensional array, thensort(X)operates along the first array dimension whose size does not equal 1, treating the elements as vectors.
[ also returns a collection of index vectors for any of
the previous syntaxes. Y,I] =
sort(___)I is the same size as X
and describes the arrangement of the elements of X into
Y along the sorted dimension. For example, if
X is an m-by-n matrix
and you sort the elements of each column (dim = 1), then each
column of I is an index vector of the sorted column of
X, such that
for j = 1:n Y(:,j) = X(I(:,j),j); end
Examples
Input Arguments
Output Arguments
Tips
Calling
sorton arrays of numbers that are not symbolic objects invokes the MATLAB®sortfunction.

