title: Scala problem using PriorityQueue non-default ordering for Stack[A]
body: <p>I'm trying to write a simple implementation of a patience sort, using Scala.<br>
  I've correctly managed to create the initial piles; however, my use of a priority queue to simplify output list generation is causing me a headache.</p>
  
  <p>It appears that my ordering implementation is either wrong or being ignored:  </p>
  
  <pre><code>def PileOrdering = new Ordering[Stack[A]] {
      def compare(a : Stack[A], b : Stack[A]) = a.head.compare(b.head)
  }
  
  // Use a priority queue, ordering on stack heads (smallest stack elems)
  val pq = new PriorityQueue[Stack[A]]()(PileOrdering)
  
  // piles is a List[Stack[A]]
  pq ++= piles
  
  // Extract an ordered list of elements
  val returnVal = (0 until count) map (_ =&gt; {
      val smallestList = pq.dequeue
      val smallestVal = smallestList.pop
  
      if (smallestList.length &gt; 0){
          pq.enqueue(smallestList)
      }
  
      smallestVal
  })
  </code></pre>
  
  <p>The PriorityQueue appears to be ordered by (I imagine the default Stack Ordering) Stack size, rather than my Ordering.</p>
  
  <p>Does anything jump out as obviously wrong?
  Any help would be greatly received.<br>
  Thanks,</p>
  
  <p><strong>Edit:</strong> I didn't make it clear in the original question: I'm using Scala 2.8.1.<br>
  <strong>Edit2:</strong> I was expecting returnVal to contain a smallest-to-largest ordering of elements, found by taking the smallest element from the heads of all stacks. Daniel has pointed out that my Ordering will order my Stacks from largest-to-smallest (the stacks themselves are already ordered correctly, with smallest element on top), which appears to be the issue. </p>