Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool sort_find(string& a, string& b){
- if(a.size() < b.size()){
- return true;
- }
- else if(a.size() > b.size()){
- return false;
- }
- else{
- for(int i=0;i<a.size();i++){
- if(a[i] == b[i] )
- continue;
- else if(a[i] < b[i]){
- return true;
- }
- else{
- return false;
- }
- }
- return true;
- }
- }
- int main(){
- string array[13]={"m","mo","moc","moch","mocha","l","la","lat","latt","latte","c","ca","cat"};
- vector<string> svector(array,array+13);
- sort(svector.begin(),svector.end(),sort_find);
- return 0;
- }
Add Comment
Please, Sign In to add comment