python 列表升序排列

简介: python

1.png

deflist_sort(lt, reverse=False):
n=len(lt)
foriinrange(n-1):
forjinrange(i+1, n):
ifreverse:
iflt[i] <lt[j]:
lt[i], lt[j] =lt[j], lt[i]
else:
iflt[i] >lt[j]:
lt[i], lt[j] =lt[j], lt[i]
lt=input().split()
list_sort(lt, reverse=False)
print(lt)


相关文章
|
18天前
|
开发工具 Python
Python列表和字典前面为什么要加星号( )?_python一个 代表列表
Python列表和字典前面为什么要加星号( )?_python一个 代表列表
|
2天前
|
索引 Python
Python利用列表、字典和zip函数处理数据
最近重温Python基础语法,一道练习题巩固下列表、字典、循环。 给定下面两个列表 attributes 和 values,要求针对 values 中每一组子列表 value,输出其和 attributes 中的键对应后的字典,最后返回字典组成的列表,请分别用一行和多行条件循环语句,来实现这个功能
|
2天前
|
Python
【Python 训练营】N_15 列表元素去重
【Python 训练营】N_15 列表元素去重
|
2天前
|
Python
Python中列表和整数相乘
【6月更文挑战第3天】
10 4
|
3天前
|
索引 Python 容器
6.Python【序列】- 列表
6.Python【序列】- 列表
|
7天前
|
存储 索引 Python
Python列表的循环遍历详解
Python列表的循环遍历详解
7 1
|
7天前
|
索引 Python
Python 列表(List)
Python 列表(List)
|
8天前
|
存储 索引 Python
Python列表
Python列表
|
9天前
|
存储 索引 Python
Python中的列表(List) 详解与高级应用
Python中的列表(List) 详解与高级应用
10 0
|
9天前
|
存储 算法 数据处理
Python中的列表(List) 类型详解与实战应用
Python中的列表(List) 类型详解与实战应用