sorted?

check if given collection is already sorted


Parameters

sorted? collection :block

Attributes

descendingcheck for sorting in ascending order

Returns

  • :logical

Examples

copy
sorted? [1 2 3 4 5] ; => true sorted? [4 3 2 1 5] ; => false sorted? [5 4 3 2 1] ; => false

copy
sorted?.descending [5 4 3 2 1] ; => true sorted?.descending [4 3 2 1 5] ; => false sorted?.descending [1 2 3 4 5] ; => false

Related