isSorted - nodef/extra-array GitHub Wiki

Examine if array is sorted.

Similar: isSorted, hasUnsortedValue, searchUnsortedValue.

function isSorted(x, fc, fm)
// x:  an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xarray = require('extra-array');

var x = [1, 2, 3, 4, 5];
xarray.isSorted(x, (a, b) => a-b);
// → true

var x = [1, 2, 8, 4, 5];
xarray.isSorted(x, (a, b) => a-b);
// → false

References