title: Sorting a map by it's element in value which is pair using C++
body: <p>How do I write custom sorting for map with such attributes --</p>
  
  <pre><code>map &lt;int, pair&lt;int,int&gt; &gt; Valuedensity
  </code></pre>
  
  <p>I want to sort with </p>
  
  <pre><code>sort(Valuedensity.begin(),Valuedensity.end(),myfn(int, pair&lt;int,int&gt;))
  </code></pre>
  
  <p>But I do not how to define this myfn() such that it sorts the map using second element in value pair of map ( <code>el.second.second</code> ).</p>