Description
I thought my comment #34744 (comment) may be distracting the original issue so I open it as a separate issue. My questions are:
- Is it possible to define
isless
for everything? - Can it have practically fast enough implementation?
- Is it reasonable to use an arbitrary ordering for
isless
?
I think the answer to point 1 is yes, since I can do isless(a, b) = isless(objectid(a), objectid(b))
. This is stupid, but I think it's OK as a proof of possibility. In particular, this means that, if we define equivalence by mapping to an integer, we get a total ordering "for free."
For point 2, I think there are cases where optimization is trivial and covers a wide range of practical use. For example, we can lower isless(a::T, b::T)
with struct type T
to isless
on the tuples of field values.
If the philosophy behind the compatibility between hasing and sorting is to support consistent behavior of hash-based and comparison-based containers, I think the answer to point 3 is yes too. But I don't think I have thought enough about it so maybe I'm missing something. In particular, it may be impossible to avoid ordering that changes julia
process to process (like how hash
behaves).