This is my code:
map<string, int> errs;
struct Compare {
bool operator() (map<string, int>::const_iterator l,
map<string, int>::const_iterator r) {
return ((*l).second < (*r).second);
}
} comp;
sort(errs.begin(), errs.end(), comp);
Can't compile. This is what I'm getting:
no matching function for call to ‘sort(..’
Why so? Can anyone help? Thanks!
You can't sort a map. It has its own sort order, defined at construction time either as the default (use <
) or a passed in comparator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With