题解 | #HJ101 输入整型数组和排序标识,对其元素按照升序或降序进行排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
http://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
Python版本
n = int(input())
vals = [i for i in map(int, input().strip().split())]
order = input()
if order == '0':
vals.sort(reverse=False)
elif order == '1':
vals.sort(reverse=True)
result = ' '.join(map(str,vals))
print(result)