← Back to problems
UNSW COMP2521 · easy

Stable Sort by Score

Stable Sort by Score

Given n records (name + score), sort by score descending; records with equal scores must keep their input order (stability). Print the names, one per line.

Input: line 1 n; then n lines name score. Output: the sorted names, one per line.

Example: Amy 90 / Ben 85 / Cara 90 / Dan 85 → Amy, Cara, Ben, Dan.