Sortable data table
Build a semantic table with stable multi-column sorting.Description
Requirements
Rows and sortable column headers are rendered with semantic table elements.
Each sortable header can be activated with either a pointer or the keyboard.
Rows with equal values retain their prior relative order after sorting.
Only the active sort header exposes the current ascending or descending aria-sort value.
Selected row IDs remain selected when sorting changes their visible positions.
Sorting and selection do not mutate the caller-provided rows array or row objects.
Stable sorting
Sort equal scores by score descending
Rows with equal scores retain their previous relative order
Constraints
Use semantic table elementsExpose aria-sortDo not mutate the input rows
Hints
Hint 1
Keep sort descriptors and selected row identifiers separate from the caller-provided data.
Hint 2
Decorate rows with their original positions before applying the active column comparisons to guarantee stable ties.
Hint 3
Render sorting controls inside column headers and expose sort direction only on the currently primary header.