title: Java: a comparator always return 1 doesn't make a priority queue into a queue?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12720293/java-strange-order-of-queue-made-from-priority-queue">Java: strange order of queue made from priority queue</a>  </p>
  </blockquote>
  
  
  
  <p>I tired to turn a priority queue into a queue by implementing the following comparator:</p>
  
  <ul>
  <li>Hack: The QueueComparator makes a PriorityQueue behaves like queue
          (FIFO) by always return 1</li>
  <li>Since the "natural ordering" of a priority queue has the least 
          element at the head and a conventional comparator returns -1 when 
          the first is less than the second, the hacked comparator always 
          return 1 so that the current (last) square will be placed at the 
          tail (recursively)</li>
  </ul>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.util.Comparator;
  public class QueueComparator implements Comparator&lt;Square&gt;{
      public int compare(Square square1, Square square2)
      {
          return 1;
      }
  }
  </code></pre>
  
  <p>But the resulting "queue" does not keep things in order(FIFO). Why?</p>