title: Use of std::greater
body: <p>I am curious about the use of <a href="http://www.cplusplus.com/reference/functional/greater/" rel="noreferrer">std::greater</a>. 
  When used with <code>sort</code>, it outputs the numbers in descending order. But when used with <code>priority_queue</code>, numbers are output in ascending order. Why so?</p>
  
  <p>Example: </p>
  
  <pre><code>#include &lt;iostream&gt;     // std::cout
  #include &lt;functional&gt;   // std::greater
  #include &lt;algorithm&gt;    // std::sort
  #include &lt;queue&gt;        // std::priority_queue
  
  int main () {
    int numbers[]={20,40,50,10,30};
    std::priority_queue&lt;int, std::vector&lt;int&gt;, std::greater&lt;int&gt;&gt; pq (numbers, numbers+5);
    std::sort(numbers, numbers + 5, std::greater&lt;int&gt;());
    while(!pq.empty()){
        std:: cout &lt;&lt; pq.top() &lt;&lt; ' ';
        pq.pop();
    }
    std::cout &lt;&lt; '\n';  
    for (int i=0; i&lt;5; i++)
      std::cout &lt;&lt; numbers[i] &lt;&lt; ' ';
    return 0;
  }
  </code></pre>
  
  <p>The output of above code is:</p>
  
  <p><code>10 20 30 40 50 
   50 40 30 20 10</code></p>
  
  <p>Or similar lines, </p>
  
  <p><code>std::priority_queue&lt;int, std::vector&lt;int&gt;, std::greater&lt;int&gt; &gt;</code> creates a min heap whereas <code>std::priority_queue&lt;int, std::vector&lt;int&gt;, std::less&lt;int&gt; &gt;</code> creates a max heap. Could have been the other way round. Why is it so?</p>