jython max function in an array -


a=[[10,1],[2,8]] 

i need find max number in 2nd column of above array.

how in jython.

simply doing max(a)[1] give 1.

thanks in advance.

-suresh

for jython 2.5 onwards ...

print max(a,key=lambda v:int(v[1]))[1] 

otherwise you're stuck loop ...

m = none  v in a:   if m none or v[1] > m:     m = v[1]  print m 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -