fork(1) download
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include<algorithm>
  5. #include<vector>
  6.  
  7.  
  8. using namespace std;
  9.  
  10. struct comp
  11. {
  12.  
  13. bool operator()( std::string lhs, std::string rhs)
  14. {
  15. std::transform(lhs.begin(), lhs.end(),lhs.begin(), ::tolower);
  16. std::transform(rhs.begin(), rhs.end(),rhs.begin(), ::tolower);
  17. return lhs < rhs;
  18. }
  19. };
  20.  
  21. int main(){
  22.  
  23.  
  24. std::string str;
  25. std::vector<std::string> v{
  26. "This is a test",
  27. "this is a test",
  28. "Cats",
  29. "cats",
  30. "this thing" };
  31.  
  32.  
  33.  
  34. std::sort(v.begin(), v.end() , comp());
  35.  
  36. for(auto &x: v)
  37. std::cout<<x<<std::endl;
  38. }
  39.  
Success #stdin #stdout 0s 3440KB
stdin
Standard input is empty
stdout
Cats
cats
This is a test
this is a test
this thing