Skip to content

Sort presets by value in list output for deterministic ordering - #262

Open
carpalsgrabby wants to merge 1 commit into
mainfrom
carpalsgrabby-patch-538140
Open

Sort presets by value in list output for deterministic ordering#262
carpalsgrabby wants to merge 1 commit into
mainfrom
carpalsgrabby-patch-538140

Conversation

@carpalsgrabby

Copy link
Copy Markdown
Owner

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.

## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant