Skip to content
Advertisement

find max , min of values in multidimensional dict

JavaScript

I want to find
1. key with max Load_1min value ,
2. key with min Load_1min value ,
3. avg value of all the load_min keys for stats.

Last one is simple – But 1st two are tough. I tried max function but failed.

Advertisement

Answer

Use the key argument to min and max:

JavaScript

In addition to iterating over the keys, this looks up every key in the dictionary. To avoid the extra lookups:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement