dir is returning items in sorted order instead of the order entered
Enum.dir() is returning items in sorted order but I need the items in the order entered. The implementation for dir seems to be correct
def __dir__(cls) -> Iterable[str]:
return list(cls._byvalue.values())
however when invoked, it returns the items in sorted order. A direct call to cls._byvalue.values() returns the correct result
>>> import pendulum
>>> from flufl.enum import Enum
>>> class OccurrenceDayOfWeek(Enum):
... M = pendulum.MONDAY
... T = pendulum.TUESDAY
... W = pendulum.WEDNESDAY
... R = pendulum.THURSDAY
... F = pendulum.FRIDAY
... S = pendulum.SATURDAY
... U = pendulum.SUNDAY
...
>>> dir(OccurrenceDayOfWeek)
['F', 'M', 'R', 'S', 'T', 'U', 'W']
>>> list(OccurrenceDayOfWeek._byvalue.values())
['M', 'T', 'W', 'R', 'F', 'S', 'U']
>>>