几个需要注意的点:

  1. input().split()需要先分割再运行int,否则是一长串字符
  2. 进行 " ".join()时,要先把整数型int转为str
while True:
    try:
        n1 = int(input())
        number = list(map(int,input().split()))
        n2  =int(input())
        if n2==0:
            new_number=sorted(number)
        else:
            new_number=sorted(number,reverse=True)
        print(" ".join(map(str,new_number)))
        
    except:
        break