Code not getting accepted

//why is the code below not working for Form Biggest //Number question
#include
#include
#include
using namespace std;
bool compare(string a,string b)
{
return a>b;
}
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
string s[n];
cin.get();
for(int i=0;i<n;i++)
{
cin>>s[i];
}
sort(s,s+n,compare);
for(int i=0;i<n;i++)
{
cout<<s[i];
}
cout<<endl;
}
return 0;
}

please give me 5 min i`ll debug it and get back to u

see since we need to make the biggest number
if we compare a = 909 and b = 9 then comparing a > b would give u true;
this would give a number 9099 since in sorted array 909 comes before 9

so in this case we need the combination 9909 since it is greater than 9099
in the custom comparator
instead of return a > b

check for a+b > b+a
this would check for 9909 & 9099 ( a + b & b+a )
which ever is greater is returned first

so

bool compare(string a,string b)
{
return a+b>b+a;
}
is the correct comparator

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.