Why `sort()` need `T` to be `Ord`?

No, the missing axioms “a < b and b == c implies a < c” and “a == b and b < c implies a < c” are necessary in order to ensure that <= is transitive. The partial preorder would furthermore require this

Note that, if you assume that PartialOrd only defines <= and all other comparisons are defined in terms of <= as I explained above

Then the

for partial_cmp are nothing more than the four different results of testing both a <= b and b <= a.

a <= b b <= a PartialOrd::partial_cmp(&a, &b)
true true Some(Equal)
true false Some(Less)
false true Some(Greater)
false false None

No, indeed not a partial order. The main point is that PartialOrd doesn't require reflexivity for <= (since it doesn't even require reflexivity for ==).

2 Likes