• Compare two values in ascending order using JavaScript's built in comparison operators.

    Type Parameters

    • T

    Parameters

    • a: T

      The left comparison value.

    • b: T

      The right comparison value.

    Returns -1 | 0 | 1

    -1 if a is less than b, 0 if a is equal to b, and 1 if a is greater than b.

    import { ascend } from "@std/data-structures";
    import { assertEquals } from "@std/assert";

    assertEquals(ascend(1, 2), -1);
    assertEquals(ascend(2, 1), 1);
    assertEquals(ascend(1, 1), 0);

    T The type of the values being compared.