fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. vector<pair<int, string>> list;
  9.  
  10. int main() {
  11. int one = 1, two = 2, three =3, five =5, six = 6;
  12. string bla = "bla";
  13.  
  14. list.push_back( pair<int, string>(two, bla));
  15. list.push_back( pair<int, string>(one, bla));
  16. list.push_back( pair<int, string>(two, bla));
  17. list.push_back( pair<int, string>(six, bla));
  18. list.push_back( pair<int, string>(five, bla));
  19.  
  20. sort(list.begin(), list.end());
  21.  
  22. for(auto item : list) {
  23. cout << item.first << endl;
  24. }
  25. }
  26.  
  27.  
Success #stdin #stdout 0s 3480KB
stdin
Standard input is empty
stdout
1
2
2
5
6