Check if an array is sorted
$ npm install is-array-sorted
import isArraySorted from 'is-array-sorted';
isArraySorted([1, 2, 3]);
//=> true
isArraySorted([1, 3, 2]);
//=> false
isArraySorted(['a', 'b', 'c']);
//=> true
Returns a boolean
.
Type: unknown[]
The array to check.
Type: object
Type: Function
Default: Ascending order ((a, b) => a - b
)
Same as Array#sort(comparator)
.