#include <bits/stdc++.h>

using namespace std;
#define int long long

std::vector<int> solve(std::vector<int> A) {
  int n = A.size();
  unordered_map<int, queue<int>> val_to_idx;
  for (int i = 0; i < n; ++i) {
    val_to_idx[A[i]].push(i);
  }

  sort(A.begin(), A.end());
  vector<int> sss(n, 0);
  sss[0] = A.front();
  for (int i = 1; i < n; ++i) {
    sss[i] = sss[i-1]+A[i];
  }

  int m = sss.back()/2+sss.back()%2;
  int last = 0;
  int front = 0;
  for (int i = n-1; i > 0; --i) {
    ++last;
    if (sss.back()-sss[i-1] >= m) {
      break;
    }
  }

  int res = sss.back()-sss[n-1-last];
  int old_used = 1e15;
  int oldest_l;
  int oldest_r;
  for (int i = 0; i < n; ++i) {
    if (last+front >= n/2) {
      oldest_l = last;
      oldest_r = front;
      break;
    }
    int old_front = front;
    int old_last = last;
    ++front;
    res += A[front-1];
    while (res >= m+A.back()) {
      res -= A[n-last];
      --last;
      if (last < 0) {
        break;
      }
      for (int j = i+1; j < n; ++j) {
        if (res >= m) {
          break;
        }
        ++front;
        res += A[front-1];
      }
    }
    if (last < 0) {
      last = old_last;
      front = old_front;
      break;
    }
    if (abs((last+front)-n/2)>abs(old_used-n/2)) {
      break;
    }
    oldest_l = last;
    oldest_r = front;
  }
  vector<int> perm;
  for (int i = 0; i < oldest_r; ++i) {
    perm.push_back(val_to_idx[A[i]].front());
    val_to_idx[A[i]].pop();
  }
  for (int i = n-oldest_l; i < n; ++i) {
    perm.push_back(val_to_idx[A[i]].front());
    val_to_idx[A[i]].pop();
  }
  for (int i = oldest_r; i < n-oldest_l; ++i) {
    perm.push_back(val_to_idx[A[i]].front());
    val_to_idx[A[i]].pop();
  }
  return perm;
}

signed main() {
  int tests;
  cin >> tests;
  for (int t = 0; t < tests; ++t) {
    int a;
    cin >> a;
    vector<int> val(a);
    for (int i = 0; i < a; ++i) {
      cin >> val[i];
    }
    val = solve(val);
    for (int i : val) {
      cout << i << " ";
    }
    cout << endl;
  }
}