title: Comparator function in C++ meaning and working?
body: <pre><code>bool comp(const pair&lt;int, int&gt;&amp; a, const pair&lt;int,int&gt;&amp; b){
      if (v[a.first]&gt;v[b.first]) {
          return true;
      }
      else if(v[a.first] == v[b.first] &amp;&amp; a.second &lt; b.second){
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>So, I was going through a code and I came across this comparator function for sorting a vector of pairs. Now, I am fairly new to C++. I tried reading on other questions as to how does this comparator work? But I am not able to understand. Why is the return type bool? And what does returning the value true means?</p>