Function naturalOrder

  • Compares the values a and b by their natural order via the < operator. Returns 0 if the values are strictly equal.

    Example

    // ascending
    [0, 3, 5, 1, 2, 4].sort(naturalOrder) == [0, 1, 2, 3, 4, 5];
    naturalOrder(-1, 1) === -1;
    naturalOrder("AA", "B") === -1; // alphabetical for strings
    naturalOrder("A", "a") === -1; // alphabetical for strings

    Type Parameters

    Type Parameters

    • T

    Parameters

    • a: T

      first value

    • b: T

      second value

    Returns number

Generated using TypeDoc