Sort presets by value in list output for deterministic ordering - #262
Open
carpalsgrabby wants to merge 1 commit into
Open
Sort presets by value in list output for deterministic ordering#262carpalsgrabby wants to merge 1 commit into
carpalsgrabby wants to merge 1 commit into
Conversation
## Summary Right now, `focus_presets.py list` prints presets in the dictionary insertion order. While this is usually stable, it's not obvious to the user and might change if the code is refactored. Sorting the output makes the CLI easier to scan and more predictable. This PR changes the `list` command to: - Sort presets by their `value` (focus) in ascending order. - Use the same sorted order in both human-readable and JSON output. ## Changes - Update `cmd_list()` to iterate over `sorted(PRESETS.values(), key=lambda p: p.value)` instead of raw `PRESETS.values()`. ## Rationale - Deterministic ordering is friendlier for users reading the CLI output. - Makes it easier to visually compare how “chill”, “balanced”, and “max” relate by focus value. - No change to the CLI interface or semantics besides the ordering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Right now,
focus_presets.py listprints presets in the dictionary insertion order. While this is usually stable, it's not obvious to the user and might change if the code is refactored. Sorting the output makes the CLI easier to scan and more predictable.This PR changes the
listcommand to:value(focus) in ascending order.Changes
cmd_list()to iterate oversorted(PRESETS.values(), key=lambda p: p.value)instead of rawPRESETS.values().Rationale