fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. int main() {
  6. std::vector<std::pair<int, int>> data {{7, 1}, {3, 2}, {8, 0}, {5, 1}, {3, 1},
  7. {2, 0}, {7, 0}, {6, 0}, {5, 0}, {3, 0}};
  8.  
  9. std::stable_sort(std::begin(data), std::end(data), [](auto const &a, auto const &b){
  10. return a.first < b.first;
  11. });
  12.  
  13. for (auto const &p : data)
  14. std::cout << p.first << " " << p.second << std::endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
2 0
3 2
3 1
3 0
5 1
5 0
6 0
7 1
7 0
8 0