Function compareNumericDescending

  • number, bigint, boolean comparator function (descending)

    Parameters

    • a: number | bigint | boolean

      first value to compare

    • b: number | bigint | boolean

      second value to compare

    Returns number

    A number indicating the sort order. -1 if a is greater than b, 1 if a is less than b, 0 if they are equal.

    Remarks

    This function is used for sorting arrays of numbers in descending order.

    Example

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

Generated using TypeDoc