Reputation: 33
I have a dictionary of 2-element-tuples as values:
d = {key0:(x0,y0), key1:(x1,y1),...,keyn:(xn,yn)}
How may I find the key with the smallest x value? If there were repeated x values, I need the key which tuple has the smallest y value.
Example 1:
INPUT: d = {key1:(3,9), key2:(2,5), key3:(8,1)}
OUTPUT: key2
Example 2:
INPUT: d = {key1:(3,9), key2:(2,5), key3:(8,1), key4:(2,1)}
OUTPUT: key4
Upvotes: 1
Views: 39