title: predicate for a map from string to int
body: <p>I have this small program that reads a line of input &amp; prints the words in it, with their respective number of occurrences. I want to sort the elements in the map that stores these values according to their occurrences. I mean, the words that only appear once, will be ordered to be at the beginning, then the words that appeared twice 7 so on. I know that the predicate should return a bool value, but I don't know what the parameters should be. Should it be two iterators to the map? If some one could explain this, it would be greatly appreciated. Thank you in advance.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;map&gt;
  
  using std::cout;
  using std::cin;
  using std::endl;
  using std::string;
  using std::map;
  
  int main()
  {
      string s;
      map&lt;string,int&gt; counters;   //store each word &amp; an associated counter
  
      //read the input, keeping track of each word &amp; how often we see it
      while(cin&gt;&gt;s)
      {
          ++counters[s];
      }
  
      //write the words &amp; associated counts
      for(map&lt;string,int&gt;::const_iterator iter = counters.begin();iter != counters.end();iter++)
      {
          cout&lt;&lt;iter-&gt;first&lt;&lt;"\t"&lt;&lt;iter-&gt;second&lt;&lt;endl;
      }
  
      return 0;
  }
  </code></pre>