categorical.sortrows
categorical: B = sortrows (A)
categorical: B = sortrows (A, col)
categorical: B = sortrows (A, direction)
categorical: B = sortrows (A, col, direction)
categorical: B = sortrows (…, 'MissingPlacement', MP)
categorical: [B, index] = sortrows (A, …)
Sort rows in a categorical array.
B = sortrows (A) sorts the rows of the 2-D categorical
array A in ascending order. The sorted array B has the same
categories as A.
B = sortrows (A, col) sorts A according to
to the columns specified by the numeric vector col, which must
explicitly contain non-zero integers whose absolute values index existing
columns in A. Positive elements sort the corresponding columns in
ascending order, while negative elements sort the corresponding columns
in descending order.
B = sortrows (A, direction) also specifies the
sorting direction, which can be either 'ascend' (default) or
'descend' applying to all columns in A. Alternatively,
direction can be a cell array of character vectors specifying
the sorting direction for each individual column of A, in which
case the number of elements in direction must equal the number of
columns in A.
B = sortrows (A, col, direction) sorts the
categorical array A according to the columns specified in col
using the corresponding sorting direction specified in direction.
In this case, the sign of the values in col is ignored. col
and direction must have the same length, but not necessarily the
same number of elements as the columns in A.
B = sortrows (…,
specifies where to place the missing elements ('MissingPlacement', MP)<undefined>)
returned in B with any of the following options specified in
MP:
'auto', which is the default, places missing elements last
for ascending sort and first for descending sort.
'first' places missing elements first.
'last' places missing elements last.
[B, index] = sortrows (A, …) also returns
an index vector containing the original row indices of A in the
sorted matrix B such that B = A(index,:).
Source Code: categorical