the following program is not taking last value of the string for comparision
for eg:
expected output
3
batman
bat
apple
actual output
batman
bat
#include< bits/stdc++.h>
using namespace std;
bool cmp(string s0,string s1){
if(s0 > s1){
return true;
}
return false;
}
int main() {
string s[100];
int t;
cin>>t;
for(int i=0;i<t;i++){
getline(cin,s[i]);
}
sort(s,s+t,cmp);
for(int i=0;i<t;i++){
cout<<s[i]<<endl;
}
return 0;
}