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