fork(21) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. int main()
  6. {
  7. std::vector<std::vector<double>> vector1 = {{4,3,5,3},
  8. {2,6,3,7},
  9. {6,8,5,1},
  10. {5,6,1,5}};
  11.  
  12. std::sort(vector1.begin(),
  13. vector1.end(),
  14. [] (const std::vector<double> &a, const std::vector<double> &b)
  15. {
  16. return a[3] < b[3];
  17. });
  18.  
  19. for (auto &r : vector1)
  20. {
  21. for (auto e : r)
  22. std::cout << e << " ";
  23. std::cout << std::endl;
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 16072KB
stdin
Standard input is empty
stdout
6 8 5 1 
4 3 5 3 
5 6 1 5 
2 6 3 7