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