title: SORT(),vector<pair<int,int> > strictly on the basis of key value even if two key value is same
body: <p>From the below code I want to sort the <code>vector&lt;pair&lt;int,int&gt; &gt;</code> using <code>sort()</code> in STL. But, the problem is that I want to <code>sort()</code> the <code>vector&lt;pair&lt;int,int&gt; &gt;</code> <strong>strictly</strong> on the basis of <strong>key</strong> even if <strong>two keys are equal</strong>. The value which was inserted first should come first. </p>
  
  <p>Here my code goes:</p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main()
  {
      long int n,k;
      cin&gt;&gt;n&gt;&gt;k;
      vector&lt;pair&lt;int,int&gt; &gt;a;
      for(int i=0;i&lt;n;i++){
          int temp;
          cin&gt;&gt;temp;
          a.push_back(make_pair(temp%k,temp));
      }
      sort(a.begin(),a.end());
      vector&lt;pair&lt;int,int&gt; &gt;::iterator it;
      for(it=a.begin();it!=a.end();it++) {
          cout&lt;&lt; it-&gt;second&lt;&lt;" ";
      }
     return 0;
  }
  </code></pre>
  
  <p><strong>Input:</strong></p>
  
  <p>let's take a basic input:</p>
  
  <blockquote>
    <p>2 7
    17 10</p>
  </blockquote>
  
  <p>Here both key value <code>17%7=3</code> and <code>10%7=3</code>.</p>
  
  <p>So I want the output 17 10 only because as key is same so, the element which is entered first should come first.</p>
  
  <p>But that's not the case instead,
  <strong>Output</strong> is :</p>
  
  <blockquote>
    <p>10 17</p>
  </blockquote>
  
  <p>Many different approach is possible. But, I want to solve this problem using sort() only. What changes can i do for my code?</p>