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

Double-checked, turns out, no. The closest thing to the axioms given for PartialOrd in the docs is just:

<= is transitive

Yup, that's it. You can define the rest:
a == b iff a <= b && b <= a
a != b iff !(a == b)
a < b iff a <= b && a != b
a > b iff b < a
a >= b iff b <= a

But it appears there's actually an axiom missing in the documentation of PartialOrd. It doesn't state anywhere that a < b and b == c implies a < c (or similarly for a == b and b < c, giving a < c). That's most likely an oversight though, I doubt that's intentional. If you add those two implications, the characterization becomes truly equivalent to “<= is transitive”.


For the record, f32 and f64 do actually form partial preorders. They do fulfill the additional constraint that a <= b implies a <= a and b <= b. (Called "partial reflexivity", or "reflexivity where the relation is defined" in the German Wikipedia article.) So if PartialOrd is just about giving a trait that floating point numbers can implement, then "partial preorder" rather than "transitive relation" would've been a valid choice, too.