test = [6,1,2,3,4,5]
a = sorted(test,reverse=True)
print a
结果如下:
[6, 5, 4, 3, 2, 1]
你可以参考下sorted,里面是可以接收reverse参数的
def sorted(iterable, cmp=None, key=None, reverse=False): # real signature unknown; restored from __doc__
""" sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list """
pass

  

05-11 22:05