Form big number

need help with this
i mean i want the comparator to sort this array
#include<bits/stdc++.h>
using namespace std;
bool compare(int a,int b){
string p = to_string(a);
string q = to_string(b);
if(p[0]==q[0]){
return p>q;
}
return p[0] > q[0];
}
int main(){

int t;
cin>>t;
while(t--){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,compare);
    for(int i=0;i<n;i++){
        cout<<a[i];
    }
}
return 0;

}

Consider a case:
1
2
98 9

Expected O/p:
998

The custom compare function must be something like this:
bool mycompare(string a,string b)
{
string ab=a+b;
string ba=b+a;
return ab>ba;
}

Now try to make the changes in your code. If still you code does not pass all the test case then please save your code on ide.codingblocks.com and then share its link.

not passing any test case now

pls check not passing any testcase

Include an endl after line 24…at the end of each test case and then check.