fork(56) 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(1);
  16. s.insert(10);
  17. s.insert(11);
  18. s.insert(100);
  19.  
  20. for (int x : s)
  21. cout << x << ' ';
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1 10 100 11