title: how to sort an array in descending order using a boolean function?
body: <p>Since I am new in competitive programming so I am finding this a bit difficult. I encountered a code and I am not able to figure it out, need some help to understand it.</p>
  <pre class="lang-cpp prettyprint-override"><code>#include&lt;iostream&gt;
  #include&lt;algorithm&gt;
  
  using namespace std;
  bool mycompare(int a ,int b){
  
      return a&gt;b;
  }
  
  int main(){
  
      int a[]={5,4,3,1,2,6,7};
      int n =sizeof(a)/sizeof(int);
  
      sort(a,a+n,mycompare);
  
      for(int i=0; i&lt;n;i++){
      cout&lt;&lt;a[i]&lt;&lt;&quot;&quot;;
      }
      return 0;
  }
  </code></pre>
  <pre><code>output:
  7 6 5 4 3 2 1 
  </code></pre>
  <p>How does this code work more specifically what does the mycompare function do in the code?</p>
  <p>My doubt is that why haven't we passed any arguments in the <code>mycompare()</code> function inside the <code>main()</code> function since the prototype of the function is</p>
  <pre class="lang-cpp prettyprint-override"><code>bool mycompare(int a, int b);
  </code></pre>