In this programming problem, you are required to write a function named sort_by_date that sorts a list of dates represented by strings in the format MMDDYYYY
(e.g., 01012023 represents Jan 1, 2023).
You can start with this template code and ensure your code can run correctly within this template:
def sort_by_date(L):
# your code here
# Note that the following code is for local testing purposes only. You should leave this part of code unchanged and not submit it to the OJ system.
T = int(input())
for t in range(T):
date_list = input().split()
sort_by_date(date_list)
print(date_list)
Please note that you only have to submit the definition of the sort_by_date
function to the OJ system. The rest of the code is for your local testing purposes only.
Input Specification
The first line of the input gives the number of test cases, , and then test cases follow.
For each test case, it will consist of a single line that contains a list of dates separated by spaces.
Constraints
Output Specification
For each test case, output a single line containing the list of dates sorted in ascending order.
Sample Input
1
01152023 01012023 12252022 07032023 04012023
Sample Output
['12252022', '01012023', '01152023', '04012023', '07032023']
Hint
sort
Comments