


def solve(arr,n):
    maxm = max(arr)
    arr.remove(maxm)
    ans=[maxm]+arr
    print(*ans)
    
    return


for _ in range(int(input())):
    n=map(int,input().split())
    arr=list(map(int,input().split()))
    solve(arr,n)


