#K91237. Sort Auction Items
Sort Auction Items
Sort Auction Items
You are given a list of auction items along with their starting bids. Your task is to sort these items in descending order based on their bid values. If two or more items have the same bid, sort those items in alphabetical order (ascending).
Mathematically, if an item i has bid \(b_i\) and name \(s_i\), then the sorting key is \((-b_i, s_i)\).
inputFormat
The input is read from stdin and formatted as follows:
- The first line contains an integer \(n\), denoting the number of auction items.
- The next \(n\) lines each describe one auction item. Each line contains an item name and its starting bid separated by spaces. Note that the item name may contain spaces, and the bid is always the last token on its line.
outputFormat
Print to stdout a single line containing the sorted auction item names, separated by a comma and a space. If there are no items (i.e. (n = 0)), output an empty line.## sample
5
Vintage Clock 200
Antique Vase 300
Painting 450
Rare Coin 300
Sculpture 150
Painting, Antique Vase, Rare Coin, Vintage Clock, Sculpture