This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients brandtbucher, cheryl.sabella, mark.dickinson, rhettinger, serhiy.storchaka, tim.peters
Date 2019-02-24.10:37:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551004668.99.0.794466274705.issue36095@roundup.psfhosted.org>
In-reply-to
Content
Agreed with Raymond and Tim here that the sorting functionality itself shouldn't be special-cased for nans.

[Tim]
> So people who go down this path can't get two steps before making a fork in the road ;-)

Well, both those solutions are wrong. *Clearly*, negative NaNs should be sorted to the start of the list, while positive NaNs are sorted to the end of the list. (Yes, I'm joking, but only a little bit: that's the result you'd get if you used IEEE 754's totalOrder to sort. But it's difficult to see how it would be useful in practice, given that people usually don't know about or care about the sign that their NaN has.)

Maybe the solution would be to provide an official "math.total_order" function that can be used as a key:

    sorted(my_list_of_floats_with_nans_in_it, key=math.total_order)
History
Date User Action Args
2019-02-24 10:37:49mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, serhiy.storchaka, cheryl.sabella, brandtbucher
2019-02-24 10:37:48mark.dickinsonsetmessageid: <1551004668.99.0.794466274705.issue36095@roundup.psfhosted.org>
2019-02-24 10:37:48mark.dickinsonlinkissue36095 messages
2019-02-24 10:37:48mark.dickinsoncreate