Multi-key sort
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.
0:00 of about 20 min
solution.py
InputExpectedGot
[[["ann",30,100],["bob",30,200],["cy",25,50]]][["cy",25,50],["bob",30,200],["ann",30,100]]not run yetsample