Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Determine whether array is sorted

`TF = issorted(`

returns
a logical scalar 1 (`A`

)`true`

) when the elements of
a vector are listed in ascending order and 0 (`false`

)
otherwise.

`TF = issorted(`

returns
1 when the elements of the first column of a matrix are sorted and
0 otherwise. If the first column contains repeated elements, then `A`

,'rows')`issorted`

looks
at the ordering of the second column to determine `TF`

.
In general, `issorted`

looks to the column immediately
to the right to determine `TF`

when the current and
previous columns have repeated elements.

For more information on sorted character and string arrays, see Sort Order for Character and String Arrays.

This syntax is not supported for a matrix of character vectors.

`TF = issorted(`

returns
1 when the elements of a string array are listed in ascending order
and 0 otherwise. A 2-D array of strings is sorted when each of the
columns is sorted. A multidimensional array of strings is sorted when
the first array dimension whose size does not equal 1 is sorted. `str`

)

Was this topic helpful?