sorted() erraticly fails to sort string numbers
Lie Ryan
lie.1296 at gmail.com
Thu Apr 30 09:47:51 EDT 2009
John Posner wrote:
> uuid wrote:
>> I am at the same time impressed with the concise answer and
>> disheartened by my inability to see this myself.
>> My heartfelt thanks!
> Don't be disheartened! Many people -- myself included, absolutely! --
> occasionally let a blind spot show in their messages to this list. BTW:
>
> container[:] = sorted(container, key=getkey)
>
> .... is equivalent to:
>
> container.sort(key=getkey)
>
Equivalent, and in fact better since the sorting is done in-place
instead of creating a new list, then overwriting the old one.
More information about the Python-list
mailing list