ascend

import { ascend } from "jsr:@ende/data-structures";

function

function ascend<T>(a: T, b: T): -1 | 0 | 1

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

a: T

The left comparison value.

b: T

The right comparison value.

Returns

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

Example: Comparing numbers

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

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

Source