Added sorting of nodes