ListTools[Sorted] - test if a list is sorted
|
Calling Sequence
|
|
Sorted(L, f, opts)
|
|
Parameters
|
|
L
|
-
|
list
|
f
|
-
|
(optional) procedure
|
opts
|
-
|
(optional) extra arguments to procedure f
|
|
|
|
|
Description
|
|
•
|
The Sorted(L) function returns the value true if list L is sorted according to certain conditions; otherwise, false is returned.
|
|
If list L is a list of numeric values, then the elements of L are tested as to whether they are in ascending order.
|
|
If L is a list of strings or symbols, the elements of L are tested as to whether they are in lexicographical order.
|
|
Otherwise, Sorted(L) tests whether the elements in list L are in address order.
|
•
|
If the optional argument f is specified as either `<` or `>`, the list must contain numeric values and the elements of the list are tested as to whether they are in ascending or descending order, respectively. Otherwise, the expression is evaluated to determine whether element x precedes element y, where x and y are consecutive elements in list L.
|
|
|
Examples
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
>
|
|
| (6) |
>
|
|
| (7) |
>
|
|
| (8) |
>
|
|
| (9) |
|
|
Download Help Document
Was this information helpful?