title: Priority queue (Min Heap) ordering in Java
body: <p>I was working with the priority queue and came across this statement.</p>
  
  <pre><code>PriorityQueue&lt;Integer&gt; heap = new PriorityQueue&lt;Integer&gt;((n1, n2) -&gt; n1 - n2);
  </code></pre>
  
  <p>Functionally I know this is a min-heap, but can someone explain to me how <code>(n1, n2) -&gt; n1 - n2</code> returns the smallest element?</p>