Only one test case passed. Please tell the problem

#include<bits/stdc++.h>
using namespace std;

bool comp(string a,string b){
if(a.length()==b.length()) return a<b;

int n = min(a.length(),b.length());
int i;
for(i=0;i<n;i++){
	if(a[i]!=b[i]) return a[i]<b[i]; 
}

if(a.length()<b.length()){
	return (a[0]<b[i]);
}

else return a[i]<b[0];

}
int main(){
int t; cin>>t;
while(t–){
int n; cin>>n;
string s[n];
for(int i=0;i<n;i++) cin>>s[i];

	sort(s,s+n,comp);

	for(int i=n-1;i>=0;i--) cout<<s[i];
	cout<<endl;
}
return 0;

}

Please Send the link of your code
how to send Link of Code ?
paste you code at

click on file->save->link will be generated
send the link of code generated
it will look like https://ide.codingblocks.com/s/258793

instead of this compare function
you can use one more simple function

bool comp(string a, string b) {
	string ab=a.append(b);
	string ba=b.append(a);

	return ab<ba;
}