def argmax(l,f=None):
if f:<EOL><INDENT>l = [f(i) for i in l]<EOL><DEDENT>return max(enumerate(l), key=lambda x:x[<NUM_LIT:1>])[<NUM_LIT:0>]<EOL>
http://stackoverflow.com/questions/5098580/implementing-argmax-in-python