Skip to content

Add result set column sorting (#34)#42

Open
muk2 wants to merge 1 commit intomainfrom
feature/issue-34-column-sorting
Open

Add result set column sorting (#34)#42
muk2 wants to merge 1 commit intomainfrom
feature/issue-34-column-sorting

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 19, 2026

Summary

  • Adds interactive column sorting in the results pane via the s key
  • Cycles through: unsorted → ascending (▲) → descending (▼) → unsorted
  • Sort indicators shown in column headers next to the sorted column name
  • Supports type-aware comparison for all CellValue types (integers, floats, text, booleans, dates, timestamps) with NULLs always sorted last
  • Cross-type numeric comparison (e.g. Int16 vs Int64, Int32 vs Float64)
  • Sort state automatically resets when executing new queries or switching between result sets (Ctrl+[/])

Changes

  • src/db/query.rs: Added sort_cmp() method on CellValue with comprehensive type-aware comparison logic and 7 unit tests
  • src/ui/app.rs: Added toggle_column_sort(), clear_sort(), rebuild_sort_indices(), and sorted_row_index() methods; added sort state fields; wired s key handler
  • src/ui/components.rs: Updated draw_result_table() to display sort indicators (▲/▼) in headers and render rows using sorted indices; added s shortcut to help overlay

Test plan

  • All 223 tests pass (7 new sorting tests)
  • cargo build compiles without warnings
  • Manual: Open results pane, press s to sort ascending, press again for descending, press again to clear
  • Manual: Switch result sets with Ctrl+[/] and verify sort resets
  • Manual: Execute new query and verify sort resets

Closes #34

🤖 Generated with Claude Code

Implements interactive column sorting for query results (#34):
- Press 's' to cycle: unsorted → ascending → descending → unsorted
- Sort indicators (▲/▼) displayed in column headers
- Supports numeric, text, boolean, date/time comparison with NULLs last
- Cross-type numeric comparison (Int16/Int32/Int64/Float32/Float64)
- Sort state resets when switching result sets or executing new queries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Feature: Result set column sorting

1 participant