ID:274051
 
How do you find the highest value in an associative list?
I want to be able to like

var/mob/Target
Target = HighestValue(List)
look up max()
In response to Metamorphman
Unfortunately max calculates the maximum of the associative keys, not the values associated with those keys. If you want to find the max of the values then you need to use a proc like this:

associative_max(list/L)
var/max
for(var/a in L)
if(max == null || L[a] > max) max = L[a]
return max