Sort tree nodes