列表排序:sort是修改原列表,sorted提供原列表的一个有序副本

li=[2,1,4,5,0]
li.sort() #默认从小到大
print li
结果:[0, 1, 2, 4, 5] li=[2,1,4,5,0]
li.sort(reverse=True) #从大小到
print li
结果:[5, 4, 2, 1, 0] li=[2,1,4,5,0]
new = sorted(li)
print new,li
结果:[0, 1, 2, 4, 5] [2, 1, 4, 5, 0] li=[2,1,4,5,0]
li.reverse() #反转列表
print li
结果:[0, 5, 4, 1, 2]

最新文章

  1. android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习
  2. 超链接的那些事(三): 属性target
  3. HDU 1248 寒冰王座(全然背包:入门题)
  4. php 抓取天气情况 www.weather.com.cn
  5. babel7-按需加载polyfill
  6. BInsertSort
  7. P1433 吃奶酪(搜索DFS+记忆化)
  8. Angular、React.js 和Node.js到底选谁?
  9. Android NDK开发调试
  10. Java排序之升序与降序
  11. 2018.10.19 NOIP模拟 加密(模拟)
  12. mysql安装(rpm)
  13. 同时安装2个版本的python
  14. WCF 之部署(2010版本之上)
  15. 20135208 JAVA第三次实验
  16. spring源码解析--事务篇(前篇)
  17. iView--3
  18. Java 基于javaMail的邮件发送(支持附件)
  19. SpringAOP源码分析总结
  20. Leetcode 557. 反转字符串中的单词 III

热门文章

  1. SQLite集成与用法
  2. 【BZOJ4373】算术天才⑨与等差数列 线段树+set
  3. Python中高层次的数据结构,动态类型和动态绑定,使得它非常适合于快速应用开发,也适合于作为胶水语言连接已有的软件部件。
  4. Failed to load http://wantTOgo.com/get_sts_token/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fromHere.com' is therefore not allowed access.
  5. 记录Elasticsearch的一次坑
  6. 【24题】P2766最长不下降子序列问题
  7. 移动App该怎样保存用户password
  8. Java中Iterator的fast-fail分析
  9. mongoDB多级子文档查询
  10. eclipse显示adb is down错误,无法真机调试