fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. const char* sort_char_array[] = { "about", "this", "and", "url", "that", "the", "i", "hi" };
  11.  
  12. sort(sort_char_array,sort_char_array+8,[](const char * a, const char * b)
  13. { return strlen(a) < strlen(b); });
  14. for( auto s: sort_char_array)
  15. cout << s << endl;
  16. }
  17.  
Success #stdin #stdout 0s 5664KB
stdin
Standard input is empty
stdout
i
hi
and
url
the
this
that
about