python sorted?
sorted?python?sorted?
sort ?
sortlistsorted?
listsortsortedlist?
sorted(iterable, cmp=None, key=None, reverse=False)
iterable --
cmp -- 1-10?
key -- ?
reverse -- ?reverse = True ? reverse = False ?
a=[5,7,6,3,4,1,2]b=sorted(a)#?a[5,7,6,3,4,1,2]b[1,2,3,4,5,6,7]L=[(b,2),(a,1),(c,3),(d,4)]sorted(L,cmp=lambdax,y:cmp(x[1],y[1]))#cmp[(a,1),(b,2),(c,3),(d,4)]sorted(L,key=lambdax:x[1])#key[(a,1),(b,2),(c,3),(d,4)]students=[(john,A,15),(jane,B,12),(dave,B,10)]sorted(students,key=lambdas:s[2])#?[(dave,B,10),(jane,B,12),(john,A,15)]sorted(students,key=lambdas:s[2],reverse=True)#?[(john,A,15),(jane,B,12),(dave,B,10)]