Move sortedTake to use PriorityQueue which is 10-100x faster