title: Copy std::map into std::vector of pairs
body: <p>I'm trying to copy a map into a vector of pair, so I can then sort the vector by the <code>second</code> data member of the pairs. I have resolved this doing like this:</p>
  
  <pre><code>void mappedWordsListSorter(){
    for (auto itr = mappedWordsList.begin(); itr != mappedWordsList.end(); ++itr){
      vectorWordsList.push_back(*itr);
    }
    sort(vectorWordsList.begin(), vectorWordsList.end(), [=](pair&lt;string, int&gt;&amp; a, pair&lt;string, int&gt;&amp; b){return a.second &gt; b.second;});
  }
  </code></pre>
  
  <p>I need to find a way to do this without using a raw loop, using the standard library instead. I have come across a lot of examples doing this by only transferring either the keys or the values of the map. I need to copy into a vector of <code>pairs&lt;string, int&gt;</code>. What is the best way to do it?</p>