Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "is-sorted"

Index

Functions

Functions

Const isSorted

  • isSorted<T>(arr: ArrayLike<T>, cmp?: Comparator<T>, start?: number, end?: number): boolean
  • Returns true if the given array and its elements in the selected index range (entire array, by default) are in the order defined by the given comparator ({@link @thi.ng/compare#compare} by default).

    remarks

    Always returns true, if effective index range (or array length) has less than two elements. No bounds checking.

    example
    isSorted([3, 2, 1])
    // false
    
    // w/ custom comparator
    isSorted([3, 2, 1], (a, b) => b - a)
    // true

    Type parameters

    • T

    Parameters

    • arr: ArrayLike<T>

      array

    • Default value cmp: Comparator<T> = compare

      comparator

    • Default value start: number = 0

      start index

    • Default value end: number = arr.length

      end index

    Returns boolean

Generated using TypeDoc