Skip to content

Latest commit

 

History

History
47 lines (28 loc) · 653 Bytes

readme.md

File metadata and controls

47 lines (28 loc) · 653 Bytes

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).