以上给出了6中对List排序的方法,其中实例3.4.5.6能起到对以List item中的某一项L = [('b',2),('a',1),('c',3),('d',4)]
A = [(x[1],i,x) for i,x in enumerate(L)] #i can confirm the stable sort
A.sort()
L = [s[2] for s in A]
L
[('a', 1), ('b', 2), ('c', 3), ('d', 4)]
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |