sort problem
Kent Johnson
kent37 at tds.net
Thu Oct 20 14:21:57 EDT 2005
Michele Petrazzo wrote:
> Lasse Vågsæther Karlsen wrote:
>
>> How about:
>>
>> list.sort(key=lambda x: x[3])
Better to use key=operator.itemgetter(3)
> Yes, on my linux-test-box it work, but I my developer pc I don't have
> the 2.4 yet. I think that this is a good reason for update :)
or learn about decorate-sort-undecorate:
lst = [ ...whatever ]
lst = [ x[3], i, x for i, x in enumerate(lst) ]
lst.sort()
lst = [ x for _, _, x in lst ]
Kent
>
> Thanks,
> Michele
More information about the Python-list
mailing list