modified Sort and added MaxPQ