recursively enforce consistent sort order