Skip to content

compute issorted

kgryte edited this page May 12, 2015 · 1 revision

Returns a boolean indicating if an input array is sorted.

var bool = compute.issorted( [ 2, 3, 5, 4 ] );
// returns false

By default, the method assumes ascending order. To impose an arbitrary sort order, provide a comparator function.

function descending( a, b ) {
	return b - a;
}

var bool = compute.issorted( [ 5, 4, 3, 2 ], descending );
// returns true
Clone this wiki locally