Can't compile std::map sorting, why?

Posted by Vincenzo on Stack Overflow See other posts from Stack Overflow or by Vincenzo
Published on 2010-05-18T12:39:41Z Indexed on 2010/05/18 12:50 UTC
Read the original article Hit count: 111

Filed under:

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!

© Stack Overflow or respective owner

Related posts about c++