In [1]:
a=[1,34,56,0,23,12,89]
In [2]:
def factor_by_6(num):
return num%6
按照对6取余来排序,这个方法可以自定义排序
In [4]:
b=sorted(a,key=factor_by_6)
b
Out[4]:
In [ ]: