排序
输入整型数组和排序标识,对其元素按照升序或降序进行排序
https://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
num1=int(input()) list1=list(input().split()) num3=int(input()) # 1.等于0,剩升序 if num3==0: list2=[] # 把list1元素提取出来,用int类型存到list2中 for i in list1: list2.append(int(i)) # list2排序 list2.sort() # list2元素逐个输出,以空格结尾 for i in list2: print(i,end=' ') else: list2=[] for i in list1: list2.append(int(i)) # sort(reverse=True) :代表降序 list2.sort(reverse=True) for i in list2: print(i,end=' ')