Check if an Array is sorted
$ npm install --save is-array-sorted
const isArraySorted = require('is-array-sorted');
isArraySorted([1, 2, 3]);
//=> true
isArraySorted([1, 3, 2]);
//=> false
isArraySorted(['a', 'b', 'c']);
//=> true
Returns a boolean.
Type: Array
Array to check.
Type: Function
Default: Ascending order ((a, b) => a - b
)
Same as Array#sort(comparator)
.
MIT © Sindre Sorhus