Fix sorting of tree items on save.