homepage

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.

classification
Title: float('nan') breaks sort() method on a list of floats
Type: behavior Stage: resolved
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, ezio.melotti, jcrocholl, mark.dickinson, rhettinger
Priority: normal Keywords:

Created on 2011年06月08日 17:39 by jcrocholl, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (3)
msg137918 - (view) Author: Johann C. Rocholl (jcrocholl) Date: 2011年06月08日 17:39
>>> l = [1.0, 2.0, 3.0, float('nan'), 4.0, 3.0, 2.0, 1.0]
>>> l.sort()
>>> l
[1.0, 2.0, 3.0, nan, 1.0, 2.0, 3.0, 4.0]
The expected result is either of the following:
[nan, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0] (similar to None)
[1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, nan] (similar to string 'nan')
msg137919 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011年06月08日 17:44
This is expected. See also #11986 and #11949.
msg137921 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011年06月08日 18:24
This is actually a duplicate of issue7915.
I don't think there is nothing we can do to improve the situation. In fact discussion at #11949 ends with a +0 from Mark Dickinson to issue a warning whenever nans participate in order comparison. Discussion at #11986 ends without any clear consensus. I think we should keep at least one issue on this topic open rather than close new issues as invalid by referring users to older closed issues that don't explain why silently producing nonsensical results is better than raising an error or issuing a warning.
History
Date User Action Args
2022年04月11日 14:57:18adminsetgithub: 56495
2011年06月08日 18:24:07belopolskysetresolution: not a bug -> duplicate
messages: + msg137921
2011年06月08日 17:44:58ezio.melottisetstatus: open -> closed

nosy: + ezio.melotti, mark.dickinson, belopolsky, rhettinger
messages: + msg137919

resolution: not a bug
stage: resolved
2011年06月08日 17:39:47jcrochollcreate

AltStyle によって変換されたページ (->オリジナル) /