Command Reference : Function Reference : Function Reference: S
  
 
@sort
 
Sort elements of matrix or vector.
Syntax: @sort(m[, o])
m: matrix or vector
o: (optional) string
Return: matrix, vector
Returns a matrix or vector containing the sorted elements of the matrix or vector object m.
Note that sorting a matrix ranks every element of the matrix and arranges the results to match the elements of the original matrix, from upper left to lower right.
The o option controls the direction of the ranking:
“a” (ascending - default) or “d” (descending)
Examples
Let M1 be an matrix. Then
= @sort(m1, "d")
returns an matrix whose elements are those of M1, sorted from largest to smallest in column-major order.
Cross-references
See also @colsort and @rowsort.
See also @ranks, @colranks, and @rowranks.
See also @capplyranks and @rapplyranks.