Form biggest number- I dont know why its giving wrong answer

#include
#include
#include
using namespace std;
bool compare(int a,int b){
return (to_string(b))<(to_string(a));
}
int main() {
int t;
cin>>t;
int n;

for(int k=0;k<t;k++){
	
	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];

    cout<<endl;
}
return 0;

}

Take input in the form of strings and then sort accordingly.
Consider a case:
1
2
98 9

Expected O/p:
998

Your O/p:
989

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;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.