String sort

#include
#include
using namespace std;
bool compare(string s,string p){
if(s[0]==p[0] && s.length()!=p.length()){
return s>p;
}
return s<p;

}
int main() {

int n;
cin>>n;
string s[n];
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]<<endl;
}
return 0;

}
where is my code going wrong?

hi @discobot,
refer this ive commented https://ide.codingblocks.com/s/664987
it checks if a string is present completely as a prefix in another string, then string with longer length should come first

Hi! To find out what I can do, say @discobot display help.