Sorting of list containing tuples
Ronny Mandal
ronnyma at math.uio.no
Thu May 18 15:42:48 EDT 2006
Uhm, thanks. (I've used lambda-sort earlier, but quite forgot......)
:)
On 18 May 2006 12:38:55 -0700, Paul Rubin
<http://phr.cx@NOSPAM.invalid> wrote:
>Ronny Mandal <ronnyma at math.uio.no> writes:
>> And now I want to sort l reverse by the second element in the tuple,
>> i.e the result should ideally be:
>>
>> l = [(6,5),(2,3),(3,2)]
>
>sorted(l, key = lambda a: -a[1])
More information about the Python-list
mailing list