Sort types before generating so that output is stable.