从具有最大lead_id(任何特定变量)的多维数组中获取数组

时间:2016-02-18 20:30:12

标签: python multidimensional-array

所以这是我的数组

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']

由于

1 个答案:

答案 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']