I have a partially sorted tuple in Python 2.x.
Why Python reverse it instead of sort it?
>>> data = (u'a', (1,), 'b ', u'b', (2,), 'c ', u'c', (3,), 'd ', u'd', (4,), 'e')
>>> sorted(data) == list(reversed(data))
True
I look forward to Python 3.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It fails because the sorting algorithm depends on a total ordering of the elements, which implies transitive
<.The ordering of unicode strings, tuples, and strings isn’t transitive:
I.e., there exists no valid sort for your list. At least not with the default comparator.