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. return a > b;
  10. }
  11. };
  12.  
  13. int main() {
  14. set<int, lexical_compare> s;
  15.  
  16. s.insert(1);
  17. s.insert(10);
  18. s.insert(11);
  19. s.insert(100);
  20.  
  21. for (int x : s)
  22. cout << x << ' ';
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
100 11 10 1