#include<bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--)
    {
    int n,m,k,i,j;
    cin>>n;
    int a[n];
    unordered_map<int,int>mp;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    int p=0;
    for(i=0;i<n;i++)
    {
        if(a[i]!=(p)&&i==0)
        {
            break;
        }
        else if(a[i]!=(p)&&a[i]!=a[i-1])
        {
            break;
        }
        else if(a[i]==(p))
        {
            cout<<a[i]<<" ";
            p++;
            mp[a[i]]--;
            if(mp[a[i]]==0)
            {
                mp.erase(a[i]);
            }
        }
    }
    for(auto &it:mp)
    {
        for(i=0;i<it.second;i++)
        cout<<it.first<<" ";
    }
    cout<<"\n";
    }

	// Write your code here
}