Sorting list of nodes