max() of a list of tuples

Lee Harr missive at frontiernet.net
Tue Jan 21 17:20:54 EST 2003


>   Here's another way:
> 
>     L = [(1,3,5), (8,16,2), (2,56,4)]
>     s = L[:]
>     s.sort(lambda x, y: cmp(x[2], y[2]))
>     print s[-1]
> 
>   Jp
> 

Yup, that is the way I would go also.

Very simple & straightforward.

(tho I might not have used a lambda ;-)






More information about the Python-list mailing list