title: How to create Priority Queue that sorts based on certain attribute of class?
body: <p>I have created a Node class: </p>
  
  <pre><code>public class Node {
  int vertex;
  double latency;
  Node predecessor;}
  
   public double getLatency()
  {
      return latency;
  }
  </code></pre>
  
  <p>I want to create a Priority Queue that sorts the Nodes by latency from least to greatest. After research, I believe I need to override the Comparator? </p>
  
  <pre><code>PriorityQueue&lt;Node&gt; pqueue = new PriorityQueue&lt;Node&gt;(numVertices, new Comparator&lt;Node&gt;({
          @Override
  
              ???
          }
      }
  </code></pre>
  
  <p>I'm not too sure how to override it. </p>