String sort problem Not able to solve

//String sort
#include
#include
#include
using namespace std;
bool mycompare(string s1,string s2){
int i;
if(s1[0]==s2[0]){
if(s1.length()>s2.length())
return s1<s2;
}

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

sort(s,s+n,mycompare);
for(i=0;i<n;i++){
    cout<<s[i]<<endl;
}

}

Other way also producing wrong output

https://ide.codingblocks.com/s/106441

@dsingh200021
You are implementing simple sorting in both your codes.
The string “bat” will always come before “batman” in this way. We need to change this order. Modify your comparator function.
Hint : You might want to use find( ) of string class.