Posts

Showing posts with the label Sort

How to sort items contained in STL maps

By definition you cannot sort a std::map by value, since a std::map sorts its elements by key. This posting documents a way to get around this by dumping std::map key-value pairs into a std::vector first, then sorting that std::vector with a less-than functor afterwards

Sorting Objects Using STL

Image
Here's an example of how using objects (hat-tip: Paul Wolfensberger )