fork download
  1. #include <algorithm> // for std::sort
  2. #include <cctype> // for std::isupper, std::tolower
  3. #include <iostream> // for std::cout
  4. #include <string> // for std::string
  5. using namespace std;
  6.  
  7. int main() {
  8. string s{"DCBAdcba"};
  9.  
  10. sort( s.begin(), s.end(), [](char x, char y) {
  11. if (isupper(x)) {
  12. if (tolower(x) == y) {
  13. return true;
  14. }
  15. }
  16. return tolower(x) < tolower(y);
  17. });
  18.  
  19. cout << s << '\n';
  20. }
  21.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
AaBbCcDd