npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

is-array-sorted

3.0.0

@sindresorhus

npmHomeRepoSnykSocket
Downloads:47946
$ npm install is-array-sorted
DailyWeeklyMonthlyYearly

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