码迷,mamicode.com
首页 > 编程语言 > 详细

python之List排序

时间:2017-12-15 13:38:29      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:list   sort   log   pytho   code   source   reverse   coding   gpo   

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排序

标签:list   sort   log   pytho   code   source   reverse   coding   gpo   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!