title: What's the logic behind the order the elements are passed to a comparison function in std::sort?
body: <p>I'm practicing lambdas:</p>
  
  <pre><code> int main()
   {
      std::vector&lt;int&gt; v {1,2,3,4};
      int count = 0;
      sort(v.begin(), v.end(), [](const int&amp; a, const int&amp; b) -&gt; bool
          {
          return a &gt; b;
          });
    }
  </code></pre>
  
  <p>This is just code from GeeksForGeeks to sort in descending order, nothing special. I added some print statements (but took them out for this post) to see what was going on inside the lambda. They print the entire vector, and the <code>a</code> and <code>b</code> values:</p>
  
  <pre><code>1 2 3 4  
  a=2 b=1
  
  2 1 3 4  
  a=3 b=2
  
  3 2 1 4  
  a=4 b=3
  
  4 3 2 1 &lt;- final
  </code></pre>
  
  <p>So my more detailed question is: 
  What's the logic behind the order the vector elements are being passed into the <code>a</code> and <code>b</code> parameters? </p>
  
  <p>Is <code>b</code> permanently at index <code>0</code> while <code>a</code> is iterating? And if so, isn't it a bit odd that the <em>second</em> param passed to the lambda stays at the <em>first</em> element? Is it compiler-specific? Thanks!</p>