Guest User

Untitled

a guest
Dec 16th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. static bool sort_find(string& a, string& b){
  2. if(a.size() < b.size()){
  3. return true;
  4. }
  5. else if(a.size() > b.size()){
  6. return false;
  7. }
  8. else{
  9. for(int i=0;i<a.size();i++){
  10. if(a[i] == b[i] )
  11. continue;
  12. else if(a[i] < b[i]){
  13. return true;
  14. }
  15. else{
  16. return false;
  17. }
  18. }
  19. return true;
  20. }
  21. }
  22.  
  23. int main(){
  24.  
  25. string array[13]={"m","mo","moc","moch","mocha","l","la","lat","latt","latte","c","ca","cat"};
  26.  
  27. vector<string> svector(array,array+13);
  28. sort(svector.begin(),svector.end(),sort_find);
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment