Function compareNumeric

  • number, bigint, boolean comparator function (ascending)

    Parameters

    • a: number | bigint | boolean

      first value to compare

    • b: number | bigint | boolean

      second value to compare

    Returns number

    A number indicating the relationship between the two numbers:

    • -1 if a is less than b
    • 1 if a is greater than b
    • 0 if a is equal to b

    Example

    const arr = [3n, true, -2n, false]
    arr.sort(compareNumeric) // [-2n, false, true, 3n]

Generated using TypeDoc