First, you should realize that == is defined for all types, but it may not do what you want for some types because it defaults to object equality. So checking whether == is defined is not helpful, even if it happens at compile time.
(Currently, method_exists is evaluated at runtime, but it's possible that this will be evaluated at compile-time for some future Julia version; see https://github.com/JuliaLang/julia/issues/7060) Normally, sorting uses isless(x,y) rather than x<y, since the isless function is guaranteed to be a total order. For example, < is not a total order on floating-point values because of NaN. for equality and ≤ consistent with isless, you could define generic functions isless_eq(x,y) = !(isless(x,y) || isless(y,x)) isless_le(x,y) = !isless(y,x) and then allow users to override isless_eq and isless_le if they have a more efficient implementation. Then when you call isless_eq or isless_le, the method-dispatch system will call the most efficient/specific version of that function automatically for you, with the decision being made at compile-time.
