I have an array of dictionary elements like this:
d = [{'k': 'k1', 'v':4}, {'k': 'k2', 'v':5}, {'k': 'k3', 'v':2}]
I would like to retrieve a value of 'k' from the the dictionary element with lowest 'v', there may be more than one with the same lowest value. In the case of the example above, I would like to get:
['k3']
This is what what I have so far, is this the most efficient and pythonic way of solving the problem (besides collapsing the two lines into one)?
m = min([x['v'] for x in d])
r = [x['k'] for x in d if x['v'] == m]
Thanks.
k3is not one of your keys.