datetime

Methods

Method Reference: datetime.sortrows

datetime: B = sortrows (A)
datetime: B = sortrows (A, column)
datetime: B = sortrows (A, direction)
datetime: B = sortrows (A, column, direction)
datetime: B = sortrows (…, 'MissingPlacement', mp)
datetime: [B, index] = sortrows (…)

Sort the rows of a datetime array.

B = sortrows (A) sorts the rows of the 2-D datetime array A in ascending order. Rows are ordered lexicographically: by the first column, ties broken by the second column, and so on. The sort is stable, so rows that compare as equal keep their original order.

B = sortrows (A, column) sorts using only the columns listed in column, in the given priority. A negative entry sorts the corresponding column in descending order. Columns not listed are not used as sort keys.

B = sortrows (A, direction) sorts every column in the given direction, either 'ascend' (default) or 'descend'. direction may also be a cell array of strings with one such value per sort column.

B = sortrows (A, column, direction) combines an explicit column list with a per-column direction.

B = sortrows (…, 'MissingPlacement', mp) controls where Not-A-Time (NaT) elements are placed. mp may be 'auto' (default; NaT sorts as the largest value, i.e. last for ascending and first for descending columns), 'first', or 'last'.

[B, index] = sortrows (…) also returns a column index vector index that maps the rows of A to B, such that B = A(index, :).

Source Code: datetime