3.0.0 • Published 3 years ago

is-array-sorted v3.0.0

Weekly downloads
30,673
License
MIT
Repository
github
Last release
3 years ago

is-array-sorted

Check if an array is sorted

Install

$ npm install is-array-sorted

Usage

import isArraySorted from 'is-array-sorted';

isArraySorted([1, 2, 3]);
//=> true

isArraySorted([1, 3, 2]);
//=> false

isArraySorted(['a', 'b', 'c']);
//=> true

API

isArraySorted(array, options?)

Returns a boolean.

array

Type: unknown[]

The array to check.

options

Type: object

comparator

Type: Function\ Default: Ascending order ((a, b) => a - b)

Same as Array#sort(comparator).