title: PriorityQueue Sort
body: <pre><code>public class Flight implements Comparable {
  </code></pre>
  
  <p>....</p>
  
  <pre><code>public int compareTo(Object obj){
      Flight f = (Flight) obj;
      Integer i1 = (Integer) f.priority;
      Integer i2 = (Integer) priority;
      if(f == null)
          return 1;
      else 
          return i2.compareTo(i1);
  }
  </code></pre>
  
  <p>....</p>
  
  <pre><code>public class JavaPriorityFlightQueue {
  
  
      public PriorityQueue flights;
  </code></pre>
  
  <p>....</p>
  
  <pre><code>public void joinQueue(Flight f){
          flights.add(f);
          Collections.sort(flights);
      }   
  </code></pre>
  
  <p>.....</p>
  
  <p>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
      The method sort(List) in the type Collections is not applicable for the arguments (PriorityQueue)</p>
  
  <pre><code>at section3.JavaPriorityFlightQueue.joinQueue(JavaPriorityFlightQueue.java:31)
  at section3.FlightTest003.main(FlightTest003.java:19)
  </code></pre>
  
  <p>I used the exact same compareTo for a LinkedList and it works, and everything is the same I have not missed something out (I think). I do not understand how it works for LinkedList but not PriorityQueue.</p>