Hacker News new | ask | show | jobs
by Cieplak 3104 days ago
Easy:

    std::vector<P> people = { P{"jane", 47}, P{"mary", 71}, P{"john", 65} };

    ranges::sort(people, [](auto& x, auto& y){ return x.weight > y.weight; });
Compile this gist with `c++ -std=c++1z -I range-v3/include`:

https://gist.github.com/cieplak/dcd587c67d989768900e4110e776...

1 comments

What if two weights are equal, the python code will also sort by name as well ;)