Guest User

Untitled

a guest
Oct 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. const char *tab[5];
  2. //then fill up the tab
  3. sort(tab, tab+5);
  4.  
  5. void sortfunc (const char *tab[], int n){
  6. filltab(tab, n); //n is the ammount of strings
  7. sort(tab, tab+n, strcmp);
  8. }
  9.  
  10. bool cmp(char const *lhs, char const *rhs) {
  11. return strcmp(lhs, rhs) < 0;
  12. }
  13.  
  14. std::sort(tab, tab + n, cmp);
  15.  
  16. std::sort(tab, tab + n, [](char const *lhs,
  17. char const *rhs) { return strcmp(lhs, rhs) < 0; });
  18.  
  19. std::vector<std::string> v = ...;
  20.  
  21. std::sort(std::begin(v), std::end(b));
  22.  
  23. bool cmp(const char *str1, const char *str2){
  24. if(strcmp(str1, str2)<0) return true;
  25. else return false;
  26. }
  27. sort(tab, tab+5, cmp);
Add Comment
Please, Sign In to add comment