Skip to main content

Practice ยท 2 of 3

Sortable Table Reducer

Write sortRows(rows, key, dir) that RETURNS rows sorted by key ("asc" or "desc", numbers and strings both supported) WITHOUT mutating the input, and nextSortDir(current) that cycles "asc" โ†’ "desc" โ†’ "asc". Stability: equal keys keep their original order.

Difficulty: intermediate

Back to lesson: Practice: Component Systems โ€” Practice