Type of function that takes a value of type T and returns a number,
denoting the order of the input value.
Type Parameters
T
The type of the input to the function
Returns
Zero if the first input value is equal to the second input value
A negative number if the first input value is less than the second input value
A positive number if the first input value is greater than the second input value
Example
constcompareNumbers: Comparator<number> = (a, b) =>a - b; // ascending order constcompareStrings: Comparator<string> = (a, b) =>a.localeCompare(b); // lexicographical order
Type of function that takes a value of type T and returns a number, denoting the order of the input value.