add sorting to tree