使用list 集合的排序功能实现排序并遍历输出
正序:
list.sort()
倒序:反转=True
list.sort(reverse=True)
def sortup(x,y,z):list1=[x,y,z]list1.sort()for i in list1:print("正序:",end="")print(i,",",end="")def sortdown(x, y, z):list1 = [x, y, z]# 反转list1.sort(reverse=True)for i in list1:print("倒序:", end="")print(i, ",", end="")def main():x = int(input("第一个数:"))y = int(input("第二个数:"))z = int(input("第三个数:"))sortup(x,y,z)print()sortdown(x,y,z)if __name__=="__main__":main()