Function reversedOrder

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

    Example

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

    Type Parameters

    Type Parameters

    • T

    Parameters

    • a: T

      first value

    • b: T

      second value

    Returns number

Generated using TypeDoc