sorted()排序
问题描述:有一个整数列表,要求调整元素顺序,把所有奇数按大小顺序放到前面,偶数按大小顺序放到后面。from random import randint
x =
print(x)
y=sorted(x, key=lambda item:-(item%2*100)+item)
print(y)
'''
'''
也可以
from random import randint
x =
print(x)
#y=sorted(x, key=lambda item:-(item%2*100)+item)
y=sorted(x, key=lambda item:(item%2==0,item))
print(y)
'''
'''
页:
[1]