fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. #include <iterator>
  6. using namespace std;
  7.  
  8. struct value {
  9. string code;
  10. string date;
  11. string name;
  12. };
  13.  
  14.  
  15. int main() {
  16. vector<value> v { { "x", "2015-02-20", "xx"}, { "y", "2013-01-12", "yy"},{ "zx", "2017-12-31", "zzxx"}};
  17. std::sort (v.begin(), v.end(), [](value&a, value&b)->bool { return a.date<b.date; });
  18. for (auto &x:v ) cout<<x.date<<endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3420KB
stdin
Standard input is empty
stdout
2013-01-12
2015-02-20
2017-12-31