| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
TF = issorted(A)
TF = issorted(A, 'rows')
TF = issorted(A) returns logical 1 (true) if the elements of A are in sorted order, and logical 0 (false) otherwise. Input A can be a vector or an N-by-1 or 1-by-N cell array of strings. A is considered to be sorted if A and the output of sort(A) are equal.
TF = issorted(A, 'rows') returns logical 1 (true) if the rows of two-dimensional matrix A are in sorted order, and logical 0 (false) otherwise. Matrix A is considered to be sorted if A and the output of sortrows(A) are equal.
For character arrays, issorted uses ASCII, rather than alphabetical, order.
You cannot use issorted on arrays of greater than two dimensions.
A = [5 12 33 39 78 90 95 107 128 131];
issorted(A)
ans =
1A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
issorted(A, 'rows')
ans =
0
B = sortrows(A)
B =
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
17 24 1 8 15
23 5 7 14 16
issorted(B)
ans =
1x = {'one'; 'two'; 'three'; 'four'; 'five'};
issorted(x)
ans =
0
y = sort(x)
y =
'five'
'four'
'one'
'three'
'two'
issorted(y)sort, sortrows, ismember, unique, intersect, union, setdiff, setxor, is*
![]() | isscalar | isspace | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |