issorted

Returns true if the array x sorted by mode. By default mode is ascending.

Syntax

issorted(x)

issorted(x, mode)

issorted(x, 'rows', mode)

Inputs

x
Any valid input.
Type: double | integer | char | string | logical | struct | cell
Dimension: scalar | string | vector | matrix
mode
Can be ascending, descending or either.
Type: char | string
Dimension: string
'rows'
Specifies to search for common rows as opposed to common elements.
Type: char | string
Dimension: string

Outputs

R
Numerical equivalent true/false.

Examples

Simple issorted example:

issorted([4,2,3,7])
ans = 0

Simple issorted example with descending option:

issorted([4,3,2,1],'descending')
ans = 1

Simple issorted example with 'rows' option:

issorted([1 2 3 4; 2 3 4 5; 4 2 3 1; 6 7 8 9],'rows')
ans = 1