# 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 matrix `A`

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 of `direction`

)`A`

is in the order specified
by `direction`

for any of the previous syntaxes.
For example, `issortedrows(A,'monotonic')`

checks
if the first column of `A`

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 of `A`

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 of `A`

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,
then `tblA`

)`issortedrows`

checks the elements in the second
variable, and so on.

If `tblA`

is a timetable, then `issortedrows`

checks
if the rows of `tblA`

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 when `tblA`

is
a timetable.

`TF = issortedrows(`

checks
if the rows of a table are sorted by row labels `tblA`

,`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 variables `tblA`

,`vars`

)`vars`

. For example, if `Age`

and `Weight`

are
variables of `tblA`

, then `issortedrows(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, then`vars`

can include the row names.If

`tblA`

is a timetable, then`vars`

can include the row times.

`TF = issortedrows(___,`

checks
if a table is sorted in the order specified by `direction`

)`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 that `issortedrows`

operates
on.

`TF = issortedrows(___,`

specifies
additional parameters for sorting tables. For example, `Name,Value`

)`issortedrows(tblA,'Var1','MissingPlacement','first')`

checks
that missing elements in `Var1`

, such as `NaN`

or `NaT`

,
are placed at the beginning of the table.

## Examples

## Input Arguments

## Extended Capabilities

**Introduced in R2017a**