title: Difference between Collections.reverseOrder vs custom comparator
body: <p>I expect the two code snippets to produce the same result, yet they don't. Why?
  The only difference is the Comparator passed to the PriorityQueue constructor.</p>
  <pre class="lang-java prettyprint-override"><code>import java.util.Collections;
  import java.util.PriorityQueue;
  
  public class PriorityQueueTest {
  
    public static void main(String[] args) {
      PriorityQueue&lt;Integer&gt; pq = new PriorityQueue&lt;&gt;(Collections.reverseOrder());
      int[] arr = {2,3,9,8,4};
      for (int i=0; i&lt;arr.length; i++) {
        pq.add(arr[i]);
      }
      while(pq.size()&gt;0) {
        System.out.println(pq.poll());
      }
    }
  }
  </code></pre>
  <p>Output (correct / expected):</p>
  <pre><code>9
  8
  4
  3
  2
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>import java.util.Collections;
  import java.util.PriorityQueue;
  
  public class PriorityQueueTest {
  
    public static void main(String[] args) {
      PriorityQueue&lt;Integer&gt; pq = new PriorityQueue&lt;&gt;((a,b) -&gt; a&gt;b ? 0 : 1);
      int[] arr = {2,3,9,8,4};
      for (int i=0; i&lt;arr.length; i++) {
        pq.add(arr[i]);
      }
      while(pq.size()&gt;0) {
        System.out.println(pq.poll());
      }
    }
  }
  </code></pre>
  <p>Output (wrong / unexpected):</p>
  <pre><code>2
  9
  8
  4
  3
  </code></pre>