A function that returns a numerical value indicating how two objects are ordered in relation to one another.
Such functions are used by various collection classes in the iModel.js library.
rhs, the function returns:
- Zero if lhs == rhs
- A negative number if lhs < rhs
- A positive number if lhs > rhs
must implement strict weak ordering, which can be summarized by the following rules:
compare(x, x)returns zero.
compare(x, y)returns zero, then so does
x == yimplies
y == x).
compare(x, y)returns non-zero, then
compare(y, x)returns a value with an opposite sign (i.e.,
x < yimplies
y > x).
compare(y, z)return non-zero values with the same sign, then
compare(x, z)returns a value with the same sign (i.e.,
x < y < zimplies
x < z).
OrderedComparator = (lhs: T, rhs: U) => number
Last Updated: 20 September, 2019