fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <cctype>
  5. #include <algorithm>
  6.  
  7. int main()
  8. {
  9. std::vector<std::string> myvector
  10. {
  11. "HELLO", "Hello", "hello",
  12. "hello", "HELLO", "Hello"
  13. };
  14. std::sort(std::begin(myvector), std::end(myvector), [](std::string const &a, std::string const &b)
  15. {
  16. return std::lexicographical_compare(std::begin(a), std::end(a), std::begin(b), std::end(b), [](std::string::value_type a, std::string::value_type b)
  17. {
  18. return std::tolower(a) < std::tolower(b);
  19. });
  20. });
  21. for(auto const &s : myvector)
  22. {
  23. std::cout << s << std::endl;
  24. }
  25. }
  26.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
HELLO
Hello
hello
hello
HELLO
Hello