`bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));`
So yes, but you were already able to use `partial_cmp` before.
`bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));`
So yes, but you were already able to use `partial_cmp` before.
I think in most cases, splitting NaNs across the start and end of the list isn't desired behavior, so I'll probably keep using partial_cmp with my own handling.
The hand-rolled solution risks inconsistency. Given the opportunity to pick the order, people are going to pick different orders, sometimes by mistake, and providing total_cmp fixes that.
I can see that in things which decided they should be Ord but internally have a f32 and so they need to implement the comparison themselves, total_cmp seems like it's almost always going to be the right choice for that unless partial_cmp with unwrap() is definitely correct and they're sure of it.
When it comes to floating point, it's probably better to bow to what IEEE 754 specifies (if it specifies something) than do what you come up yourself, even if it's less useful. x != x holding true for NaNs is another example here.
[1] Actually, the sort order of NaN payloads is implementation-defined, but given the nice bit representation mentioned above is easy to implement, you're probably unlikely to see any other implementation.