Here's an example where this issue produces invalid results in
Python.
>>> NaN = float("nan")
>>> arr = [1.0, 4.0, 3.0, 2.0, 5.0, NaN, 6.0, 3.0, NaN, 0.0, 1.0, 4.0,
3.0, 2.0, 5.0, NaN, 6.0, 3.0, NaN, 0.0]
>>> sorted(arr)
[0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 5.0, nan, 5.0,
6.0, nan, 4.0, nan, 6.0, nan]
The sorted numerical values aren't in order. Note the 4.0 near the end,
after the 6.0. "sort" has failed because it assumes that a< b and b<
c implies a< c. But that's not a valid assumption here.