Why this is giving wrong answers?

hello @dhruvilcodes

inbuilt sort function will not work here.
for example->
1
2
21 2
ur code will give 212 as answer
but correct answer should be 221.
.
write ur own custom comparator and it should look like->

bool cmp(string a,string b){
return a+b > b+a;
}

and then print ur array from index [ 0 … n-1]