题解 | 定义sortArray函数
输入整型数组和排序标识,对其元素按照升序或降序进行排序
https://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
while True:
try:
n = int(input())
array = list(map(int, input().split()))
t = int(input())
def sortArray(x, y):
if y == 0:
return sorted(x)
if y == 1:
return sorted(x, reverse = True)
s = sortArray(array, t)
for i in range(len(s)):
print( s[i], end = ' ')
except:
break

