[issue36095] Better NaN sorting.

Brandt Bucher report at bugs.python.org
Sun Feb 24 09:22:12 EST 2019


Brandt Bucher <brandtbucher at gmail.com> added the comment:

One other idea I had considered was having a new magic method intended to be used for elementwise comparisons such as these (I’m thinking specifically of the old __cmp__/tp_compare). Sorting routines could check for this method on each element, but fall back on __lt__ if it is missing or NotImplemented. 

This would allow us to define an ordering for types independent of the rich comparison behavior. Simply defining it for floats and adding quick patches for list.sort/min/max/... would provide the language (and users) with that flexibility.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36095>
_______________________________________


More information about the Python-bugs-list mailing list