题解 | #输入整型数组和排序标识,对其元素按照升序或降序进行排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
http://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
n = int(input())
ls = list(map(int, input().split())) # 需要转成整数,才能排序
rnk = int(input())
if rnk == 0:
ls.sort()
ls = map(str,ls) # 需要转回字符串,才能拼接
print(' '.join(ls))
elif rnk == 1:
ls.sort(reverse=True)
ls = map(str, ls)
print(' '.join(ls))