--- id: ordered-enum version: "0.0.10" license: unclear license_treatment: unclear maintenance: active --- # ordered-enum — A small library for adding total orderings to enums License: unclear · Maintenance: active · Downloads: 152.1K/mo ## What it is and what it does ordered_enum is a minimal library that makes Python enum members comparable and sortable by implementing total ordering. It provides two base classes: OrderedEnum, which orders members by their definition sequence in the class body, and ValueOrderedEnum, which orders members by their assigned values. The library requires Python 3.9 or newer and has no external dependencies, making it a lightweight addition to projects that need to sort or compare enum states. The typical use case is state machines or priority systems where you want to compare enum members directly (e.g., State.Running < State.Waiting) or sort collections of them. OrderedEnum is more flexible since it doesn't require unique values; ValueOrderedEnum enforces uniqueness but orders by the numeric or comparable value you assign to each member. Use it for: - Implement state machines where you need to check if one state is 'before' or 'after' another in a defined sequence. - Sort priority or severity enums (e.g., log levels) by their numeric values without manual conversion. - Build workflow systems that compare enum states to determine valid transitions or precedence. - Create ordered status enums for database records or API responses that need to be ranked or filtered. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds comparison operators to Python enums so they can be sorted and compared using standard ordering syntax, with two strategies: ordering by definition sequence or by member values. Yes, if you need enum comparison. The package is lightweight, actively maintained, has no dependencies, and solves a real gap in Python's standard enum module. The only caveat is the unclear license status—verify that it's compatible with your project's requirements before committing to it. ## Install pip install ordered-enum uv add ordered-enum poetry add ordered-enum ## Installing ordered-enum Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release (417 days ago) and a live repository. Quickstart: from ordered_enum import OrderedEnum class State(OrderedEnum): Disabled = 4 Loaded = 3 Waiting = 2 Running = 1 Dead = 0 print(State.Disabled > State.Loaded) # True print(sorted([State.Dead, State.Waiting])) # [State.Waiting, State.Dead] Requires Python 3.9 or newer. Verify before relying: - Whether the package is suitable for production use given the unclear license status and lack of explicit license declaration. ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 152.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags enum comparison operators, sortable enums, ordered enum, enum total ordering, comparable enum members, enum-utilities, ordering [View on SkillFed](https://skillfed.io/packages/ordered-enum) · [View on PyPI](https://pypi.org/project/ordered-enum/)