In Python I have some data that looks like this:
A = [
(-9, [(2, 3), (5, 2), (3,1)]),
(-8, [(3, 4), (5, 6), (7, 6)]),
(-8, [(0, 0), (5, 0), (1, 6)]),
(-9, [(2, 3), (4, 2), (4, 5)]),
]
What is the most pythonic way to extract the element or elements that have the maximum value in the first entry? Changing the data structure is not an option.
In this example, the goal is to return the two middle tuples.
Cheers!
Try a list comprehension:
See it working online: ideone