← Back to problems
UNSW COMP2521 · hard

21T3 Q6 — Stable sort of students

stdin: first line N ORDER where ORDER is BY_ZID or BY_NAME; then N lines <zid> <name> (name is one token). Print the records sorted: BY_ZID → ascending zid; BY_NAME → ascending name, ties broken by ascending zid (stable secondary key). One <zid> <name> per line.


Single-file C (gcc -O0 -Wall). Self-contained reframing of the exam's ADT-completion question. From COMP2521 21T3 Sample.