1.字典排序
from numpy import*
from numpy import linalg as la
A=[('a',2),('b',1),('c',5)]
print(sorted(A, key=lambda jj : jj[1], reverse=True))
sorted(A, key=lambda jj : jj[1], reverse=True)[:2]
[('c', 5), ('a', 2), ('b', 1)]
[('c', 5), ('a', 2)]
1.字典排序
from numpy import*
from numpy import linalg as la
A=[('a',2),('b',1),('c',5)]
print(sorted(A, key=lambda jj : jj[1], reverse=True))
sorted(A, key=lambda jj : jj[1], reverse=True)[:2]
[('c', 5), ('a', 2), ('b', 1)]
[('c', 5), ('a', 2)]