tags:

views:

15

answers:

1

Is there a way to sort std::map by the data rather than the key? Right now my code duplicates the entire map in to an array just to do this.

+1  A: 

As far as I can remember, std::map will give you the iterator that will go through the items sorted by the key. Only way to go through the sorted items by the value, and still use the map, is to rewrite whole collection to another map, with key and value reversed.

Daniel Mošmondor
I found that using a single vector and simply finding stuff was better.
Jookia