@stdlib/array-base-assert-is-sorted-ascending
v0.1.1
Published
Test if an array is sorted in ascending order.
Readme
isSortedAscending
Test if an array is sorted in ascending order.
Installation
npm install @stdlib/array-base-assert-is-sorted-ascendingUsage
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 falseIf provided an empty array, the function returns false.
var out = isSortedAscending( [] );
// returns falseExamples
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 falseNotice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
