Monday, 12 August 2013

Find the top value from a list of tuples

Find the top value from a list of tuples

If I have this list of tuples:
[('123c', 0.0), ('123c1', 0.0), ('123c2', 0.10456917162915072), ('123c3',
0.097595441008939465), ('123c4', 0.0), ('12c35', 0.0), ('13836',
0.040490933063262943)]
How can I find the top value in the whole list, and return the first
element in the tuple it belongs?
For the example above, the result would be: '123c2' because
0.10456917162915072 is the top value
Thanks

No comments:

Post a Comment