Exlanation of my code

I am using this method to compare two integers lexicographically and then pass it as function the sort function but I am getting the wrong answer.
Can you tell me where am I going wrong with my approach.
#Code
bool compare(int a, int b)

{
string s_a = to_string(a) ;
string s_b = to_string(b) ;
return s_a > s_b ;
}

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] ;
	}
	cout << endl ;
}
return 0;

}

@akabhi83229
I have corrected your code. There was a mistake with the comparator
we compare s_a + s_b > s_b + s_a ; we arrange in such a way, whichever makes the largest number.

Thanks for the help.