#C449. Sorting Dates with Multiple Formats

    ID: 48033 Type: Default 1000ms 256MiB

Sorting Dates with Multiple Formats

Sorting Dates with Multiple Formats

You are given a list of date strings, each formatted in one of several possible formats:

\(YYYY-MM-DD\) (e.g., 2023-01-15), \(DD-MM-YYYY\) (e.g., 15-01-2023), or \(Month\ DD,\ YYYY\) (e.g., January 15, 2023).

Your task is to parse these dates, sort them in ascending order, and output the sorted dates in the YYYY-MM-DD format.

The problem requires you to handle multiple date formats. If a date string does not match any of the accepted formats, you may assume that such cases do not occur in the input. The solution should read input from standard input and write output to standard output.

inputFormat

The input is read from standard input and is formatted as follows:

  1. The first line contains an integer \(n\), the number of dates.
  2. The following \(n\) lines each contain a date string in one of the following formats: \(YYYY-MM-DD\), \(DD-MM-YYYY\), or \(Month\ DD,\ YYYY\).

outputFormat

The program should output exactly \(n\) lines where each line contains a sorted date in the format YYYY-MM-DD.

## sample
5
2023-01-15
15-01-2023
January 15, 2023
2023-02-28
28-01-2023
2023-01-15

2023-01-15 2023-01-28 2023-02-28 2023-02-28

</p>