fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. using namespace std;
  5.  
  6. struct lexical_compare {
  7. bool operator() (int a, int b) const {
  8. return to_string(a) < to_string(b);
  9. }
  10. };
  11.  
  12. int main() {
  13. set<int, lexical_compare> s;
  14.  
  15. s.insert('a');
  16. s.insert('b');
  17. s.insert('c');
  18. s.insert('d');
  19.  
  20. for (int x : s)
  21. cout << x << ' ';
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5440KB
stdin
Standard input is empty
stdout
100 97 98 99