duration

Methods

Method Reference: duration.sortrows

duration: B = sortrows (A)
duration: B = sortrows (A, col)
duration: B = sortrows (A, direction)
duration: B = sortrows (A, col, direction)
duration: B = sortrows (…, 'MissingPlacement', MP)
duration: [B, index] = sortrows (A, …)

Sort rows in a duration array.

B = sortrows (A) sorts the rows of the 2-D duration array A in ascending order. The sorted array B has the same size 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 either a string array or 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 number of elements, but not necessarily equal to the columns of A.

B = sortrows (…, 'MissingPlacement', MP) specifies where to place the missing elements (NaN) 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: duration