Fix sorting of nodes