sort the nodes in a priority queue