Make priority sorting stable for tied records

Original practice scenario: a help desk serves higher-priority requests first; requests with equal priority must stay in input order. A Request has char id[9] and int priority. Input gives 0<=n<=6 and n unique id/priority pairs, where ids are tokens of 1..8 characters and priorities are 0..100. Write a stable descending-priority sort based on selecting the best remaining request. Select the first maximum, save that whole record, shift intervening records right by one, and insert the saved record at the current position. Print each id|priority on its own line, or EMPTY when n=0. Show every pass for A 3, B 2, C 3, D 2, E 4. Explain why choosing the first maximum but merely swapping does not guarantee stability; give a concrete counterexample.


