title: reordering priority_queue based on condition c++
body: <p>I am trying to reorder priority_queue based on user demand.</p>
  
  <p>This is the data struct: </p>
  
  <pre class="lang-cpp prettyprint-override"><code>struct Person { 
  
      int age; 
  
      float height; 
  };
  </code></pre>
  
  <p>I used this struct separately to reorder it in a decreasing way</p>
  
  <pre><code>struct CompareHeight { 
      bool operator()(Person const&amp; p1, Person const&amp; p2) 
      { 
          // return "true" if "p1" is ordered  
          // before "p2", for example: 
          return p1.height &gt; p2.height; 
      } 
  } HI; 
  </code></pre>
  
  <p>and I used this struct separately to reorder it in an increasing way</p>
  
  <pre><code>struct CompareHeightInv { 
      bool operator()(Person const&amp; p1, Person const&amp; p2) 
      { 
          // return "true" if "p1" is ordered  
          // before "p2", for example: 
          return p1.height &lt; p2.height; 
      } 
  } HD; 
  </code></pre>
  
  <p>and I call each speratlly by:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>priority_queue&lt;Person, vector&lt;Person&gt;, CompareHeightInv&gt; inc; 
  
  priority_queue&lt;Person, vector&lt;Person&gt;, CompareHeight &gt; dec; 
  </code></pre>
  
  <p>My question is: is there a way that like this</p>
  
  <pre><code>class Foo {
  private:
       ...
       priority_queue&lt;Person, vector&lt;Person&gt;, something&gt; myQueue; 
       ...
  public:
       Foo (bool flag) {
            if (flag)
               myQueue is increasing
            else
               myQueue is deacreasing
       }
  
  }
  </code></pre>