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 mjpieters
Recipients docs@python, mjpieters, rhettinger
Date 2019-01-03.21:35:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, the sorting HOWTO at contains the text:

> The sort routines are guaranteed to use __lt__() when making comparisons between two objects. So, it is easy to add a standard sort order to a class by defining an __lt__() method

Nowhere else in the Python documentation is this guarantee made, however. That sort currently uses __lt__ only is, in my opinion, an implementation detail.

The above advice also goes against the advice PEP 8 gives:

> When implementing ordering operations with rich comparisons, it is best to implement all six operations (__eq__, __ne__, __lt__, __le__, __gt__, __ge__) rather than relying on other code to only exercise a particular comparison.
> To minimize the effort involved, the functools.total_ordering() decorator provides a tool to generate missing comparison methods.

The 'guarantee' seems to have been copied verbatim from the Wiki version of the HOWTO in, where that part of the Wiki page was added by an anonymous user in revision 44 to the page:

Can this be removed from the HOWTO?
Date User Action Args
2019-01-03 21:35:45mjpieterssetrecipients: + mjpieters, rhettinger, docs@python
2019-01-03 21:35:41mjpieterssetmessageid: <>
2019-01-03 21:35:41mjpieterslinkissue35654 messages
2019-01-03 21:35:40mjpieterscreate