ListTools
Sorted
test if a list is sorted
Calling Sequence
Parameters
Description
Examples
Sorted(L, f, opts)
L
-
list
f
(optional) procedure
opts
(optional) extra arguments to procedure f
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 fx,y,opts is evaluated to determine whether element x precedes element y, where x and y are consecutive elements in list L.
withListTools:
L≔William,Henry,George,Edward
SortedL
false
SortedsortL,lexorder
true
L≔−0.984,−0.733,−0.254,0.305,0.768,0.992,0.906,0.537,0.,−0.537,−0.906
SortedsortL,`>`
SortedsortL,`>`,`>`
Sortedseqexpi,i=−10..10,verify,less_than
Sortedseqsini,i=−10..10,verify,less_than
See Also
map
sort
type[list]
type[numeric]
type[string]
type[symbol]
Download Help Document