is-array-sorted

Check if an Array is sorted

MIT 3 个版本
安装
npm install is-array-sorted
yarn add is-array-sorted
pnpm add is-array-sorted
bun add is-array-sorted
README

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

版本列表
3.0.0 2021-08-11
2.0.0 2019-04-18
1.0.0 2017-01-23