title: Sorting multimap with both keys and values
body: <p>I am tryin to sort a multimap that have set of pairs in it using standard sort function by writing a compare function for it, but I am getting some error in it. I am trying to sort the map with values and then again sort it with keys. Compare function is causing some error. Can you point out where I am going wrong with this.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;map&gt;
  
  using namespace std;
  
  bool cmp(const pair&lt;int,int&gt;&amp; a, const pair&lt;int,int&gt;&amp; b)
  {
      return a.second &lt; b.second;
  }
  
  int main() {
      // multimap of int ssId, int phone numbers
      multimap &lt;int, int&gt; m;
      m.insert(make_pair(1, 8));
      m.insert(make_pair(1, 5));
      m.insert(make_pair(2, 4));
      m.insert(make_pair(2, 3));
      m.insert(make_pair(3, 1));
  
      sort(m.begin(), m.end(), cmp);
      return 0;
  }
  </code></pre>
  
  <p>Output should be like:<br/></p>
  
  <pre><code>1 5
  1 8
  2 3 
  2 4
  3 1
  </code></pre>