Sort the enums in a stable manner