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

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 f⁡x&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

> 

with⁡ListTools&colon;

> 

L≔William&comma;Henry&comma;George&comma;Edward

L≔William&comma;Henry&comma;George&comma;Edward

(1)
> 

Sorted⁡L

false

(2)
> 

Sorted⁡sort⁡L&comma;lexorder

true

(3)
> 

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

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)
> 

Sorted⁡L

false

(5)
> 

Sorted⁡sort⁡L&comma;`>`

false

(6)
> 

Sorted⁡sort⁡L&comma;`>`&comma;`>`

true

(7)
> 

Sorted⁡seq⁡exp⁡i&comma;i=−10..10&comma;verify&comma;less_than

true

(8)
> 

Sorted⁡seq⁡sin⁡i&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]