Code Room
CodingMediumcod-g1159
Subject Database queryLevel Mid–Senior~20 minCommon in Databases & SQL · Algorithms & data structures interviewsIndustries Software development

Question

Implement ORDER BY age ASC, salary DESC, name ASC for a query result. Given rows as [name, age, salary] (name string, age and salary integers), return the rows sorted by age ascending, then by salary descending, then by name ascending as a final stable tie-break. Return the full rows in sorted order. Up to 10000 rows.

Implement
order_by_multi(rows: list[list]) → list[list]
Examples
in[[["ann",30,100],["bob",30,200],["cy",25,50]]]out[["cy",25,50],["bob",30,200],["ann",30,100]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.