sorting a tuple

Quinn Dunkan quinn at
Wed Nov 15 03:47:34 CET 2000

On Wed, 15 Nov 2000 01:13:21 GMT, etsang at <etsang at> wrote:
>I forgot to mention that the tuple is only containg integers. E.g.
>items = ('1','2','3','4','5','6')
>And I want to sort it in decending order with a built in library
>funciton if possible to make code clean

There are no integers in that tuple :)  But, to sort it:

def rev_sort(x):
    y = list(x)
    return y

Answers to possible questions you may have:
Q: "Why must I copy the tuple to a list?"
A: Tuples cannot be modified.  That's the whole point.
Q: Isn't there a nicer way to reverse sort?
A: No.  See the FAQ (this way *is* nice).

More information about the Python-list mailing list