You can't sort an std::map. An std::map is always sorted according to its keys.
If you need the items in an std::map sorted by a different criterion then you need to copy them somewhere else (like onto a vector) and sort them there.
Oops. My bad, I misread your code. I thought map was an std::map instead of an std::vector. You should avoid doing stuff like that.
std::map<int, int> string;
You should preferably name containers based on what data they contain; failing that, you should name them according to the type that they are, especially if the function is going to handle multiple containers.
return a.second < b.second;//i get and error here
Never say "an error". If you get an error then say what error you're getting. We can't look at your screen.