timetable.issortedrows
timetable: TF = issortedrows (tt)
timetable: TF = issortedrows (tt, rowDimName)
timetable: TF = issortedrows (tt, vars)
timetable: TF = issortedrows (tt, …, direction)
timetable: TF = issortedrows (…, Name, Value)
True when the rows of a timetable are already in a given order.
TF = issortedrows (tt) returns true when the rows
are in ascending order of their row times, which is the order
sortrows would put them in with nothing else asked.
Every form sortrows accepts is accepted here and asks the same
question of it: the row dimension name, one or more variables named,
indexed or selected, a direction, and the 'MissingPlacement'
and 'ComparisonMethod' pairs. A direction must follow the
keys it applies to, as it must there.
The sort is stable, so the answer is exactly whether sorting would leave every row where it already is.
See also: issorted, sortrows, timetable
Source Code: timetable
issortedrows asks whether the rows are already in the order sortrows would put them in, and takes every form sortrows does. With nothing else asked, that order is ascending row times.
t0 = datetime (2024, 1, 1); Depth = [12; 45; 23; 8]; TT = timetable (Depth, 'RowTimes', t0 + hours ([2 0 3 1])')
TT =
4x1 timetable
Time Depth
____________________ _____
01-Jan-2024 02:00:00 12
01-Jan-2024 00:00:00 45
01-Jan-2024 03:00:00 23
01-Jan-2024 01:00:00 8
issortedrows (TT)
ans = 0
issortedrows (sortrows (TT))
ans = 1
Name a variable or a direction to ask a narrower question. The sort is stable, so the answer is exactly whether sorting would leave every row where it already is.
t0 = datetime (2024, 1, 1);
TT = timetable ((1:6)', [10;20;30;40;50;60], 'RowTimes', ...
t0 + hours (0:5)', 'VariableNames', {'A', 'B'});
issortedrows (TT, 'B')
ans = 1
issortedrows (TT, 'B', 'descend')
ans = 0
A numeric index counts the variables, and a negative one asks about descending order.
issortedrows (TT, -1)
ans = 0