title: Wrong order in java.util.PriorityQueue and specific Comparator
body: <p>i am very confused with this little example of java.util.PriorityQueue and my own Comparator:</p>
  
  <p>In this code i get a wrong order in the queue.
  The result is: <code>5,8,7</code>instead of <code>5,7,8</code>
  Is there anything wrong with my <code>Comparator&lt;Vertex&gt;</code> ? Thank you for your help.</p>
  
  <pre><code>public class Test {
  
  public static void main(String[] args) {
      PriorityQueue&lt;Vertex&gt; priorityQueue = new PriorityQueue&lt;Vertex&gt;(new Comparator() {
          @Override
          public int compare(Object o1, Object o2) {
              Vertex u = (Vertex) o1;
              Vertex v = (Vertex) o2;
              return Integer.compare(new Integer(u.distance), new Integer(v.distance));
          }
      });
  
      Vertex vertex1 = new Vertex(1);
      Vertex vertex2 = new Vertex(2);
      Vertex vertex3 = new Vertex(3);
      Vertex vertex4 = new Vertex(4);
  
      vertex1.distance = 8;
      vertex2.distance = 5;
      vertex3.distance = 7;
  
  
      priorityQueue.add(vertex1);
      priorityQueue.add(vertex2);
      priorityQueue.add(vertex3);
  
  }
  
  private static class Vertex {
      int distance;
      int id;
  
      public Vertex(int id) {
          this.id = id;
      }
  }
  }    
  </code></pre>