/*
  _      __        __         __        ____                    ___    _                   __
 | | /| / / ___ _ / /_ ____  / /       / __ \  ___  ___        / _ \  (_) ___  ____ ___   / /
 | |/ |/ / / _ `// __// __/ / _ \     / /_/ / / _ \/ -_)      / ___/ / / / -_)/ __// -_) /_/ 
 |__/|__/  \_,_/ \__/ \__/ /_//_/     \____/ /_//_/\__/      /_/    /_/  \__/ \__/ \__/ (_)  
                                                                                             
*/
 
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define allr(v, l, r) v.begin() + l, v.begin() + r;
#define endl "\n"
#define newline cout << endl;
using namespace std;

// constants
const int INF = 1e9;

// functions

// structs

// globals

// notes
/*
 -stuff you should look for-
* int overflow, array bounds
* special cases (n=1?)
* do something instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH

continue - skip the rest in the loop
*/

void solve()
{
    int n;
    cin >> n;
    vector <int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    
    ll S = accumulate(all(A), 0LL);
    sort(all(A));
    
    vector <int> res;
    ll best = 1LL * INF * INF;
    do
    {
        ll cur = 0;
        for (int i = 0; i < n; i++)
        {
            cur += 1LL * A[i];
            if (2 * cur >= S)
            {
                break;
            }
        }
        
        if (abs(cur - S + cur) < best)
        {
            res = A;
            best = abs(cur - S + cur);
        }
    }
    while (next_permutation(all(A)));
    
    for (auto x : res)
    {
        cout << x << ' ';
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        newline
    }
}

/*
$$$$$$$$\ $$$$$$$$\ 
$$  _____|\____$$  |
$$ |          $$  / 
$$$$$\       $$  /  
$$  __|     $$  /   
$$ |       $$  /    
$$$$$$$$\ $$$$$$$$\ 
\________|\________|
*/