Sorting NaNs

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Jun 2 20:08:08 EDT 2018


On Sat, 02 Jun 2018 21:51:16 +0100, Ben Bacarisse wrote:

> Paul Rubin <no.email at nospam.invalid> writes:
> 
>> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
>>> it too will mess up sorting in unpredictable ways. So don't do that.
>>
>> Hmm.  GHCi 7.4.2:
>>
>>     Prelude> let x = 0.0 / 0.0
>>     Prelude> x
>>     NaN
>>     Prelude> x==x
>>     False
>>     Prelude> :m Data.List
>>     Prelude Data.List> sort [1,2,x,4,5]
>>     [1.0,2.0,4.0,5.0,NaN]
> 
> But
> 
>   Prelude Data.List> sort [1,x,2,4,5]
>   [2.0,4.0,5.0,NaN,1.0]


Thanks Ben, and Paul (unfortunately I don't see Paul's messages for some 
reason).

If users of the statistics library would like to see better or different 
support for NANs, I urge you to let me know.





-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson




More information about the Python-list mailing list