[Raymond Bisdorff <raymond.bisdo...@pt.lu>] > ... > Please notice the following inconsistency in Python3.10.0 and before of > a sort(reverse=True) result: > > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(reverse=True) > >>> L > >>> [(3, 'e'), (2, 'd'), (2, 'b'), (1, 'c'), (1, 'a')]
Looks good to me. > it should be: > > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> reverseTuplesSort(L) > [(3, 'e'), (2, 'b'), (2, 'd'), (1, 'a'), (1, 'c')] Stability is irrelevant in the example, because no two list elements are equal. You appear to be thinking, perhaps, that s[0] == t[0] when s == (1, 'a') and t == (1, 'c') means s and t "are equal", but that's not so at all. >>> s = (1, 'a') >>> t = (1, 'c') >>> s == t False >>> s < t True >>> t > s True So s MUST come before t in a forward sort, and t MUST come before s in a reverse sort. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/V22SQQI4FC4XD4TNCCXWBLCOCH2W4XU3/ Code of Conduct: http://python.org/psf/codeofconduct/