Ties need the item number
transcript
Sort a shelf by band, then rating. Two items tie on both. Who goes first?
Item one and item two share a band. They share a rating too. The statement says the lower number goes first.
A C plus plus sort may reorder equal keys. Your answer then depends on the language. A judge will reject that.
Use a key of three parts. The band comes first, then the rating, high first. The item number comes last.
On the sample, items one and two tie. The item number puts one first. All four languages print the same order.
Make every key different. Sort the item numbers, not the values. Then print the order once.
In Python, the key is a tuple of three values. In Java and C plus plus, write a comparator. In JavaScript, subtract the values in the same order.
Build inputs with many equal keys on purpose. Run the program twice, in two languages. The outputs must match exactly.
Break every tie. Use the item number. Full breakdown in the lecture.