issortedrows
Determine if matrix or table rows are sorted
Syntax
Description
TF = issortedrows(
returns the logical scalar 1 (A
)true
) when the elements of the first column of a matrixA
are listed in ascending order. Otherwise,issortedrows
returns 0 (false
). When the first column has consecutive repeated elements,issortedrows
determines whether the next column is in ascending order, and repeats this behavior for succeeding equal values.
TF = issortedrows(___,
returns 1 when the first column ofdirection
)A
is in the order specified bydirection
for any of the previous syntaxes. For example,issortedrows(A,'monotonic')
checks if the first column ofA
is in ascending or descending order.direction
can also be a cell array of character vectors representing multiple directions for each column being checked. For example,issortedrows(A,[2 3],{'ascend' 'descend'})
checks if the second column ofA
is in ascending order, then checks if the third column is in descending order to break ties.
TF = issortedrows(___,
specifies additional parameters for checking sort order. For example,Name,Value
)issortedrows(A,'ComparisonMethod','abs')
checks if the elements in the first column ofA
are sorted by magnitude.
TF = issortedrows(
checks if the rows of a table are in ascending order based on the elements in the first variable. If elements in the first variable are repeated, thentblA
)issortedrows
checks the elements in the second variable, and so on.
IftblA
is a timetable, thenissortedrows
checks if the rows oftblA
are in ascending order based on its row times. Row times of a timetable label the rows along the first dimension of the timetable.
TF = issortedrows(
checks if the rows of a table are in ascending order based on its row names. Row names of a table label the rows along the first dimension of the table.tblA
,'RowNames')
This syntax is not supported whentblA
is a timetable.
TF = issortedrows(
checks if the rows of a table are sorted by row labelstblA
,rowDimName
)rowDimName
along the first dimension.
If
tblA
is a table, then the labels are row names.If
tblA
is a timetable, then the labels are row times.
TF = issortedrows(
checks if the rows of a table are in ascending order based on the elements in variablestblA
,vars
)vars
. For example, ifAge
andWeight
are variables oftblA
, thenissortedrows(tblA,{'Age','Weight'})
checks if the rows are in ascending order by age, then by weight to break ties.
If
tblA
is a table with row names, thenvars
can include the row names.If
tblA
is a timetable, thenvars
can include the row times.
TF = issortedrows(___,
checks if a table is sorted in the order specified bydirection
)direction
for any of the previous table syntaxes.direction
can be a single sort order such as'descend'
or'monotonic'
, which is applied to each specified variable, row name, or row time.direction
can also be a cell array whose elements contain different sort orders for each specified variable, row name, or row time thatissortedrows
operates on.
TF = issortedrows(___,
specifies additional parameters for sorting tables. For example,Name,Value
)issortedrows(tblA,'Var1','MissingPlacement','first')
checks that missing elements inVar1
, such asNaN
orNaT
, are placed at the beginning of the table.