std::map sort by data?

2019-05-04 10:28发布

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条回答
倾城 Initia
2楼-- · 2019-05-04 11:03

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.

查看更多
登录 后发表回答