#K70622. Sort Supplies by Expiration Date
Sort Supplies by Expiration Date
Sort Supplies by Expiration Date
You are given a list of supplies, each with a name and an expiration date. Your task is to sort the supplies in ascending order by their expiration date. If two supplies have the same expiration date, they should be sorted by their names in alphabetical order.
The expiration date is provided in the format (YYYY-MM-DD). You need to ensure that the sorting is stable and the supplies are output in the correct order.
inputFormat
The input begins with an integer (n) ((0 \leq n \leq 10^5)), the number of supplies. The next (n) lines each contain a supply description with two tokens: the name (a string without spaces) and the expiration date in the format YYYY-MM-DD.
outputFormat
Output the sorted list of supplies. For each supply, print the name and the expiration date separated by a space on a new line. If the list is empty (i.e., when (n = 0)), do not output anything.## sample
4
Rice 2023-07-10
SoySauce 2023-06-15
Tofu 2023-05-01
Seaweed 2023-05-01
Seaweed 2023-05-01
Tofu 2023-05-01
SoySauce 2023-06-15
Rice 2023-07-10
</p>