>
> Did you try to sort a tuple ?
>
>  >>> (1, "aaa").sort()
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> AttributeError: 'tuple' object has no attribute 'sort'

I can do this:

>>> x = (3,2,1)
>>> x = tuple(sorted(list(x)))

Which, although senseless, effectively sorts the x tuple. But, you are
right, I am not really sorting the tuple, I'm sorting a list, which
has been made from the tuple, then changing it back to a tuple.

Actually, I can even do it in one line:

x = tuple(sorted(list((3,2,1))))


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to