[Solved] How to sort elements of pairs inside vector?

You just: std::sort(v.begin(), v.end()); std::pair is lexicographically compared. On the other hand if you want to sort them with respect the second element of the std::pair then you would have to defind a custom comparator in the following manner: std::sort(v.begin(), v.end(), [](std::pair<int, std::string> const &p1, std::pair<int, std::string> const &p2) { return (p1.second == p2.second)? p1.first … Read more

[Solved] std::vector inserting std::pair

The original poster failed to actually post the code that was causing the problem. He has since edited my post with the correct code that demonstrates the problem. The code that demonstrates the problem follows: template <class R, typename B=int> class AVectorContainer { public: AVectorContainer() {} typedef R* ptr_Type; typedef const B & const_ref_Type; typedef … Read more