title: My overloading operator < don't apply to sort function in cpp
body: <p>I want to overload operator &lt; between 2 pair. It works when i compare using &lt; but it doesn't work when i use sort function built_in cpp.
      #include 
      using namespace std;</p>
  
  <pre><code>typedef pair&lt;int,int&gt; pii;
  
  bool operator &lt; (const pii &amp;a,const pii &amp;b){
      return a.second&lt;b.second;
  }
  
  int main()
  {
      pii a,b;
      a=make_pair(1,4);
      b=make_pair(2,3);
      if(a&lt;b) cout&lt;&lt;"a&lt;b\n";
      else cout&lt;&lt;"b&lt;a\n";
  
      vector&lt;pii&gt; v;
      v.push_back(a);
      v.push_back(b);
      sort(v.begin(),v.end());
  
      for(auto x:v)
          cerr&lt;&lt;x.first&lt;&lt;" "&lt;&lt;x.second&lt;&lt;endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>b&lt;a
  1 4
  2 3
  </code></pre>
  
  <p>I 'm confused why it doesn't print:</p>
  
  <pre><code>b&lt;a
  2 3
  1 4
  </code></pre>