Skip to content

Modern Array IsSorted

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Array › Array Container › IsSorted

IsSorted

Returns true if the Array is already in ascending order.

Syntax

IsSorted( a )

Notes

  • / IsSortedBy( a, less )

Examples

#import "std/containers"
using containers

dim v as Array( of int32 )
v.Push( 1 ) : v.Push( 2 ) : v.Push( 2 ) : v.Push( 3 )

print IsSorted( v )      '' true -- equal neighbours are still sorted

v.Push( 0 )
print IsSorted( v )      '' false

'' Cheap enough to use as a guard before a sort that is usually redundant
if not IsSorted( v ) then Sort( v )
print IsSorted( v )      '' true

Library: Array Container
Category: Array
Documented under: Sorting

Clone this wiki locally