首页 > 编程语言 > 详细

python之List排序

时间:2017-12-15 13:05:02      阅读:205      评论:0      收藏:0      [点我收藏+]

sorted()

#coding:utf-8
#sorted Ascending 升序
L = [12,23,43,3,65,34,21,3645]
print(sorted(L))

>>>output
[3, 12, 21, 23, 34, 43, 65, 3645]


#sorted Descending 降序
print(sorted(L,reverse = True))

>>>output
[3645, 65, 43, 34, 23, 21, 12, 3]

sort()

python之List排序

原文:http://www.cnblogs.com/pualus/p/8042449.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!