C
cesco
I'm designing an algorithm with maps that need the elements to be
sorted by value instead of by key. Does anyone have a suggestion on how
to do that?
#include <map>
using namespace std;
int main()
{
// how can I specify a SortingCriterion based on the value so that
// the months are ordered from the one with largest number of day
// to the one with smallest?
map<const char*, int /*, SortingCriterion*/ > months;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
}
Thanks & regards
Francesco
sorted by value instead of by key. Does anyone have a suggestion on how
to do that?
#include <map>
using namespace std;
int main()
{
// how can I specify a SortingCriterion based on the value so that
// the months are ordered from the one with largest number of day
// to the one with smallest?
map<const char*, int /*, SortingCriterion*/ > months;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
}
Thanks & regards
Francesco