timetable

Methods

Method Reference: timetable.issorted

timetable: TF = issorted (tt)

True when the row times of a timetable are in ascending order.

TF = issorted (tt) returns true when each row time is at or after the one before it. The ordering is not strict, so repeated times are sorted; a timetable with any missing row time is not, and one with fewer than two rows has nothing out of order and so is. Only the row times are read: the variables take no part.

This is the whole of the question issorted answers here. It takes no dimension, no direction and no options; use issortedrows to ask about a direction, about a variable, or about where missing values should fall.

A table has no issorted, its row names being labels rather than an ordering.

See also: issortedrows, sortrows, timetable

Source Code: timetable

issorted asks one question: are the row times in ascending order? The ordering is not strict, so repeated times are sorted.

 t0 = datetime (2024, 1, 1);
 Reading = [12; 20; 25; 44];
 issorted (timetable (Reading, 'RowTimes', t0 + hours (0:3)'))
ans = 1
 issorted (timetable (Reading, 'RowTimes', t0 + hours ([2 0 3 1])'))
ans = 0
 issorted (timetable (Reading, 'RowTimes', t0 + hours ([0 1 1 3])'))
ans = 1

A missing row time leaves a timetable unsorted, and a timetable with fewer than two rows has nothing out of order.

 t0 = datetime (2024, 1, 1);
 issorted (timetable ([1; 2; 3], 'RowTimes', [t0; NaT; t0 + hours(2)]))
ans = 0
 TT = timetable ((1:4)', 'RowTimes', t0 + hours (0:3)');
 issorted (TT(1,:))
ans = 1

For anything beyond that question, ask issortedrows instead.

 issortedrows (TT, 'Time', 'descend')
ans = 0