is-array-sorted
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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

Package Sidebar

Install

npm i is-array-sorted

Weekly Downloads

1,686

Version

3.0.0

License

MIT

Unpacked Size

3.41 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus