title: Comparator for min-heap in C++
body: <p>I am trying to make a min-heap<sup>1</sup> of <code>long</code>s in C++ using the STL <code>make_heap</code>, etc., but my comparator doesn't seem to be comparing properly. The following is my current comparator:</p>
  
  <pre><code>struct greater1{
      bool operator()(const long&amp; a,const long&amp; b) const{
          return a&gt;b;
      }
  };
  </code></pre>
  
  <p>However, when I do <code>std::pop_heap(humble.begin(),humble.end(),g);</code> where <code>g</code> is an instance of <code>greater1</code> and <code>humble</code> is a heap who makes <code>[9,15,15,25]</code> when <code>sort_heap</code> is called, I get a <code>15</code> popped.</p>
  
  <p>Is my comparator correct? what might be going wrong?</p>
  
  <p>EDIT:<br>
  I realized that I am running sort_heap with no comparator, whereas when I run it this comparator, I get <code>[15,15,9,25]</code> from <code>sort_heap</code>. Now I am thinking my comparator is definitely not working, but unsure why. </p>
  
  <p><sup>1</sup>The STL makes a max-heap by default, so I need a comparator.</p>