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

OK, I admit that's a bit weird, but still:

f32::NAN == f32::NAN is also false, so the two copies of NAN are not the same thing according to the floating point interpretation. Every copy of NAN is a different thing. It works fine with the definition of partial ordering, it's just that NAN.clone() creates a different object that is not equal. I guess even every time you look at the same copy of NAN it's a different thing, hmm. Weird, but I guess still workable.

Maybe you could argue that f32 doesn't really have a partial order (I would say it's close enough), but even if so, doesn't mean the trait is not a partial order trait, it's just that impl PartialOrder for f32 doesn't do the right thing.

2 Likes