title: How to sort a vector or deque KeyPair
body: <p>I have a <code>deque &lt;pair&lt;int, int&gt; &gt; r;</code>.
  I need to sort all by second parameter, and return a <code>deque&lt;int&gt;</code> of first all parameters.
  For example:</p>
  
  <pre><code>deque&lt;pair&lt;int, int&gt; &gt; r;
  r.push_back(make_pair(1, 5));
  r.push_back(make_pair(0, 8));
  r.push_back(make_pair(7, 3));
  r.push_back(make_pair(2, 1));
  </code></pre>
  
  <p>I need this result</p>
  
  <pre><code>{2, 7, 1, 0}
  </code></pre>
  
  <p>I have a working method that "brute force" all value to N<sup>2</sup>, but it's very bad.
  Maybe there exists something this <code>std::</code>? I hope you help me.</p>