MaxGraey / is-array-sorted

Check if an Array is sorted

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is-array-sorted Build Status

Check if an Array is sorted

Install

$ npm install --save is-array-sorted

Usage

const isArraySorted = require('is-array-sorted');

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

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

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

API

isArraySorted(input, [comparator])

Returns a boolean.

input

Type: Array

Array to check.

comparator

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

Same as Array#sort(comparator).

License

MIT © Sindre Sorhus

About

Check if an Array is sorted

License:MIT License


Languages

Language:JavaScript 100.0%