title: Sorting std::map using value
body: <p>I need to sort an <code>std::map</code> by value rather than by key. Is there an easy way to do it?</p>
  
  <p>I got one solution from the follwing thread:<br/>
  <a href="https://stackoverflow.com/questions/3992874/stdmap-sort-by-data">std::map sort by data?</a> <br/>
  Is there a better solution? <br/></p>
  
  <pre><code>map&lt;long, double&gt; testMap;
  // some code to generate the values in the map.
  
  sort(testMap.begin(), testMap.end());  // is there any function like this to sort the map?
  </code></pre>