Function compareNumber

  • Number comparator function (ascending)

    Parameters

    • a: number

      first value to compare

    • b: number

      second value to compare

    Returns number

    The difference between the two numbers

    Remarks

    This function subtracts the second number from the first number and returns the result.

    Example

    const arr = [3, 1, 4, 1, 5]
    arr.sort(compareNumber) // [1, 1, 3, 4, 5]

Generated using TypeDoc