Use a more efficient sort on the list of nodes

 - Cache the subroutine results, to improve speed when comparing.  More
   noticeable on a large number of nodes.