Skip to main content

Practice ยท 2 of 3

Sortable Table Reducer

CHALLENGE
Difficulty: intermediate+25 XP

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.

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