-
Notifications
You must be signed in to change notification settings - Fork 5
isSorted
Subhajit Sahu edited this page May 3, 2023
·
1 revision
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