Formed largest possible number

#include
#include
using namespace std;
bool compare(string a, string b)
{
return a>b;
}
int main()
{
int t;
cin>>t;
while(t–)
{
int m;
cin>>m;
string s[m];
for(int i=0;i<m;i++)
{
cin>>s[i];
}
sort(s, s+m, compare);
string ans;
for(int i=0;i<m;i++)
{
ans+=s[i];
}
cout<<ans<<endl;
}

return 0;

}

what’s wrong in this code? answer is showing correct but couldn’t even passed the single test case!!

hello @sourav_817
your comparator is not correct.
for example -> for input 2 21
your comparator order them as 212 but correct order should be 221.

so change ur comparator.
it should be
return a+b > 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.