PY-12213 When moving, members should be sorted according to their dependencies