所以这是我的数组
x=[['56','xyz','xyz@gmail.com','123456789'],['623','yzx','yzx@gmail.com','95134786'],['901','dvjs','dvjs@yahoo.in','945678123']]
如何选择具有最高第一指数的数组,即在这种情况下结果应为
['901','dvjs','dvjs@yahoo.in','945678123']
由于
答案 0 :(得分:3)
将max
与指定的密钥一起使用:
>>> x=[['56','xyz','xyz@gmail.com','123456789'],['623','yzx','yzx@gmail.com','95134786'],['901','dvjs','dvjs@yahoo.in','945678123']]
>>>
>>> selection = max(x, key=lambda item: int(item[0]))
>>> selection
['901', 'dvjs', 'dvjs@yahoo.in', '945678123']