Does anyone know of a good way to sort an stl map?
I have something like the following example:
#include <iostream>
#include <map>
#include <algorithm>
int main()
{
map<int, float> map_to_sort;
// Populate the map with between 20 - 2000 elements
map_to_sort.sort();
}
Obviously I am aware that map<> doesn't have a sort function :op so does anyone have a quick method of sorting through a map?
From the best I can see I am going to have to manually iterate through all elements of the map and compare and move to a seperate map, I am hoping there is a better solution than this since that seems like a wasteful use of CPU time, this is for a searchengine project I am working on and as can be expected time is critical in this application, especially considering I actually need to sort through 3 seperate maps.
Any help would be really appreciated.
Best regards
Ben