Returns a negative number when a sorts before b, a positive number when
a sorts after b and zero when they are equal. It must be a consistent
total order (reflexive, antisymmetric and transitive) and must never return
NaN. The tree may call it with its arguments in either order.
It must not modify the tree it orders: a mutating method of that tree called
from the comparator throws a TypeError and leaves the tree unchanged.
Reading the tree or modifying other trees is allowed, but searches of that
tree (has, get, floor, range, ...) and its iterators resuming after a
change call the comparator again, so they need a guard against infinite
recursion.
Defines the sort order of a tree.
Returns a negative number when
asorts beforeb, a positive number whenasorts afterband zero when they are equal. It must be a consistent total order (reflexive, antisymmetric and transitive) and must never returnNaN. The tree may call it with its arguments in either order.It must not modify the tree it orders: a mutating method of that tree called from the comparator throws a
TypeErrorand leaves the tree unchanged. Reading the tree or modifying other trees is allowed, but searches of that tree (has,get,floor,range, ...) and its iterators resuming after a change call the comparator again, so they need a guard against infinite recursion.