How can I get the first value of a tuple in a tuples list where second value is the minor?
mylist = [(a, date_a), (b, date_b), ..., (z, date_z)]
If date_d
is the minor of all dates how can I get d
?
CodePudding user response:
The min
builtin actually accepts an optional key
callable as a parameter, just like sorted
, where it is more known.
which means you can customize what does it mean to be "minimal" for your sequence:
min_item = min(mylist, key item: item[1])[0]