datetime.sort
datetime: B = sort (A)
datetime: B = sort (A, dim)
datetime: B = sort (A, direction)
datetime: B = sort (A, dim, direction)
datetime: B = sort (…, 'MissingPlacement', mp)
datetime: [B, I] = sort (…)
Sort a datetime array.
B = sort (A) returns the elements of the datetime array
A sorted in ascending order along its first non-singleton
dimension. For a matrix, each column is sorted independently. Sorting is
stable: elements that compare as equal keep their original relative order.
B = sort (A, dim) sorts along dimension
dim.
B = sort (A, direction) sorts in the order given
by direction, which is either 'ascend' (default) or
'descend'.
B = sort (…,
controls where Not-A-Time ('MissingPlacement', mp)NaT) elements are placed. mp may
be 'auto' (default; NaT last for ascending order and first
for descending order), 'first', or 'last'.
[B, I] = sort (…) also returns an index array
I of the same size as A such that B is A indexed
by I along the operating dimension.
Source Code: datetime
sort orders datetimes chronologically.
t = datetime (2024, 3, [9, 2, 20, 5])
t =
1x4 datetime array
09-Mar-2024 02-Mar-2024 20-Mar-2024 05-Mar-2024
sort (t)
ans =
1x4 datetime array
02-Mar-2024 05-Mar-2024 09-Mar-2024 20-Mar-2024