Comparator for string

I am not getting correct answer on using the compare function
#include
#include
#include
#include
using namespace std;
bool compare(char a,char b){
return a>b;
}
int main() {
int t,n;
cin>>t;
while(t–){
cin>>n;
int a[n];
ostringstream str1[n];
string s[n];
for(int i=0;i<n;i++){
cin>>a[i];
str1[i]<<a[i];
s[i]=str1[i].str();

	}
	sort(s,s+n,compare);
	for(int i=0;i<n;i++)

{
cout<<s[i];
}

}
return 0;

}

a and b indvidually dont matter, what matters is which which form the bigger number a+b or b+a, so you need to compare a+b with b+a
Correct Code

Can’t understand why we are comparing a+b with b+a

Is it like for a=54 b=546 a+b=54546 and b+a=54654 and thus b+a > a+b ?

we are comparing a+b with b+a because if a is placed before b then the number would include a+b else the number would include b+a and since we want to maximize the number we need to compare a+b with b+a

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.