I am writing a simple program that reads in a plain text file (ignoring numbers/symbols) and stores each unique word and the frequency it appears in the text file. This information is stored in a multimap<string, int>. I want to sort the elements in the multimap so as to facilitate efficient searching, meaning I want the words that have the highest associated frequency to be the first element in the multimap.
I'm not sure how exactly to go about doing this. Should it be done while the program is parsing in the text file? Or what would the best way to manipulate the structure. I'm thinking that maybe copying the elements one by one into another map might be the best way to go this, but I'm not sure.
Any comments are appreciated