Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

isSortedAscending

Test if an array is sorted in ascending order.

Usage

var isSortedAscending = require( '@stdlib/array/base/assert/is-sorted-ascending' );

isSortedAscending( x )

Tests if an array is sorted in ascending order.

var out = isSortedAscending( [ 1, 2, 3 ] );
// returns true

out = isSortedAscending( [ 3, 2, 1 ] );
// returns false

If provided an empty array, the function returns false.

var out = isSortedAscending( [] );
// returns false

Examples

var AccessorArray = require( '@stdlib/array/base/accessor' );
var isSortedAscending = require( '@stdlib/array/base/assert/is-sorted-ascending' );

var x = new AccessorArray( [ 1, 2, 3, 4 ] );
var bool = isSortedAscending( x );
// returns true

x = new AccessorArray( [ 1, 1, 1, 1 ] );
bool = isSortedAscending( x );
// returns true

x = new AccessorArray( [ 1 ] );
bool = isSortedAscending( x );
// returns true

x = new AccessorArray( [ 1, 3, 2, 4 ] );
bool = isSortedAscending( x );
// returns false

x = new AccessorArray( [ 4, 3, 2, 1 ] );
bool = isSortedAscending( x );
// returns false