add `compare` module with comparators

Take two. The heap code will follow later.
I think I'm reasonably happy with the status quo. Making it public is an... interesting... idea, but something that can be done later in a back-compat way.