fork download
  1. #include <list>
  2. #include <iostream>
  3.  
  4. int main() {
  5. typedef void linearVariable; // Dummy to make the code compile.
  6. typedef std::pair<linearVariable*, double> weightedVariable;
  7. std::list<weightedVariable> tmp;
  8.  
  9. tmp.emplace_back(std::make_pair(nullptr, 0.4));
  10. tmp.emplace_back(std::make_pair(nullptr, 0.8));
  11. tmp.emplace_back(std::make_pair(nullptr, 0.2));
  12.  
  13. tmp.sort([](const weightedVariable& a, const weightedVariable& b) {
  14. return a.second < b.second;
  15. });
  16.  
  17. for (auto const &wv : tmp)
  18. std::cout << wv.second << std::endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
0.2
0.4
0.8