String sort (Some test cases are failing don't know why)

#include <bits/stdc++.h>

#define ll long long

using namespace std;

bool compare(string s1,string s2)

{

if(s1[0]==s2[0])

{

    if(s1.size()>s2.size())

        return true;

    else

        return false;

}

else

{

    if(s1>s2)

        return false;

    else

        return true;

}

}

int main(){

ll n;

cin>>n;



cin.get();

string s[10001];

for(ll i=0; i<n; i++){

    getline(cin,s[i]);

}

sort(s,s+n,compare);

for(ll i=0; i<n; i++){

    cout<<s[i]<<endl;

}

}