We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A medium frontend problem, graded against 6 test cases (3 of them hidden).
React and browser-platform problems - hooks, event handling, and rendering behaviour.
Reach for it when you see: A component, hook, or DOM-behaviour question rather than an algorithm.
More Frontend problems →1. Column-wide type decision. Deciding per pair (`a` numeric and `b` numeric → numeric compare) gives inconsistent comparators that violate the sort contract. Decide once: numeric if *every* cell parses, else string.
2. Stability under `desc`. `sort(cmp).reverse()` reverses the ties too. Negate the comparison instead: `direction === "desc" ? -cmp : cmp`.
3. Moving nodes. `appendChild` on a node that already has a parent *moves* it, so appending the rows back in sorted order reorders the table in place - event listeners, focus, and any state on the rows survive. Rebuilding via `innerHTML` would destroy all of that.
Time: O(n log n). Space: O(n) for the row array.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
Read off this problem's own test suite, so these are the cases a submission actually has to survive.
These apply to the pattern as a whole, not just this problem.