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