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 yanmitrofanov
Recipients docs@python, yanmitrofanov
Date 2020-01-04.15:29:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578151795.43.0.682291916428.issue39210@roundup.psfhosted.org>
In-reply-to
Content
Sorting documentation claims that sorting algorithm is only using < comparisons
https://docs.python.org/3/howto/sorting.html#odd-and-ends
https://docs.python.org/3/library/stdtypes.html#list.sort

When __lt__ implementation is missing, you get an exception
class Foo:
    pass
sorted([Foo(), Foo(), Foo()])
TypeError: '<' not supported between instances of 'Foo' and 'Foo'

However, if implement __gt__ method, you doesn't get an exception
class Foo:
    def __gt__(self, other):
        return False
sorted([Foo(), Foo(), Foo()])  # ok


Is it supposed to work like this? Or is it lack of documentation?
History
Date User Action Args
2020-01-04 15:29:55yanmitrofanovsetrecipients: + yanmitrofanov, docs@python
2020-01-04 15:29:55yanmitrofanovsetmessageid: <1578151795.43.0.682291916428.issue39210@roundup.psfhosted.org>
2020-01-04 15:29:55yanmitrofanovlinkissue39210 messages
2020-01-04 15:29:55yanmitrofanovcreate