sort nodes in tree