#K2491. Sort Dates in Ascending Order
Sort Dates in Ascending Order
Sort Dates in Ascending Order
You are given a list of date strings in the format YYYY-MM-DD
. Your task is to sort these dates in ascending order. The dates are guaranteed to be valid, and sorting them lexicographically will yield the correct order. In particular, if you are given n dates, you need to output the sorted dates, each on a new line.
Formally, if the input contains dates \(d_1, d_2, \dots, d_n\), you are to compute a permutation \(p\) such that \(d_{p_1} \le d_{p_2} \le \dots \le d_{p_n}\) holds. Use the built-in sorting functionality if available.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(n\), the number of dates.
- The second line contains \(n\) space-separated date strings in the format
YYYY-MM-DD
.
outputFormat
Output the sorted list of dates to standard output (stdout), with each date on a new line, in ascending order.
## sample3
2021-07-19 2022-01-01 2021-03-15
2021-03-15
2021-07-19
2022-01-01
</p>