Pythonic way to find key of weighted minimum and maximum from a dictionary

I’m working with a dataset similar to this:

animals = {
            "antelope": {
                "latin": "Hippotragus equinus", 
                "cool_factor": 1, 
                "popularity": 6
            "ostrich": {
                "latin": "Struthio camelus", 
                "cool_factor": 3, 
                "popularity": 3
            "echidna": {
                "latin": "Tachyglossus aculeatus", 
                "cool_factor": 5, 
                "popularity": 1

What I’m looking to do is find the “least cool” and “coolest” animal weighted by popularity, such that:

> min_cool_weighted(animals)

> max_cool_weighted(animals)

The solution that comes to me first is to create 3 arrays (keys, cool_factors, and popularities), loop through the dictionary, push all the values into the 3 arrays, then create a fourth array with each value where weighted[i] = cool_factor[i] * popularity[i], then take the min/max and grab the corresponding key from the key array. However, this doesn’t seem very Pythonic.

Is there a better, more expressive way?

Best answer

max and min should suffice

min(animals, key=lambda x: animals[x]["cool_factor"]*animals[x]["popularity"])
max(animals, key=lambda x: animals[x]["cool_factor"]*animals[x]["popularity"])