title: Why priorityQueue is not sorting the elements
body: <p>I have below piece of code</p>
  
  <pre><code>        Comparator&lt;StudentDTO&gt; compareNames = Comparator.comparing(StudentDTO::getName);
      PriorityQueue&lt;StudentDTO&gt; h = new PriorityQueue&lt;&gt;(compareNames);
  
      h.offer(new StudentDTO(5, "c"));
      h.offer(new StudentDTO(2, "b"));
      h.offer(new StudentDTO(8, "z"));
      h.offer(new StudentDTO(1, "a"));
  </code></pre>
  
  <p>System.out.println(h);</p>
  
  <p>And I am getting output as below:</p>
  
  <pre><code>[StudentDTO [rollNo=1, Name=a], StudentDTO [rollNo=2, Name=b], StudentDTO [rollNo=8, Name=z], StudentDTO [rollNo=5, Name=c]]
  </code></pre>
  
  <p>Not sure why Name=z is coming before Name=c.
  Edit: I am using java 8.</p>