Sorted - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ListTools

  

Sorted

  

test if a list is sorted

 

Calling Sequence

Parameters

Description

Examples

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 fx&comma;y&comma;opts is evaluated to determine whether element x precedes element y, where x and y are consecutive elements in list L.

Examples

withListTools&colon;

LWilliam&comma;Henry&comma;George&comma;Edward

LWilliam&comma;Henry&comma;George&comma;Edward

(1)

SortedL

false

(2)

SortedsortL&comma;lexorder

true

(3)

L0.984&comma;0.733&comma;0.254&comma;0.305&comma;0.768&comma;0.992&comma;0.906&comma;0.537&comma;0.&comma;0.537&comma;0.906

L−0.984&comma;−0.733&comma;−0.254&comma;0.305&comma;0.768&comma;0.992&comma;0.906&comma;0.537&comma;0.&comma;−0.537&comma;−0.906

(4)

SortedL

false

(5)

SortedsortL&comma;`>`

false

(6)

SortedsortL&comma;`>`&comma;`>`

true

(7)

Sortedseqexpi&comma;i=10..10&comma;verify&comma;less_than

true

(8)

Sortedseqsini&comma;i=10..10&comma;verify&comma;less_than

false

(9)

See Also

list

ListTools

map

sort

type[list]

type[numeric]

type[string]

type[symbol]