Dsa
Sorting
Easy
Order of Events
You are given a list of tasks, each with a title and a timestamp indicating when it was created. Your task is to sort these tasks primarily by their creation timestamp. If two tasks have the same timestamp, sort them alphabetically by title. Input will be provided with each task on a new line containing the title and timestamp separated by a comma. The timestamp is in the format 'YYYY-MM-DD HH:MM'. Output the sorted tasks in the same format as input, one per line.
Example:
Input:
Task A, 2023-10-01 10:00
Task B, 2023-09-30 09:00
Task C, 2023-10-01 10:00
Output:
Task B, 2023-09-30 09:00
Task A, 2023-10-01 10:00
Task C, 2023-10-01 10:00
Key concepts
sortingarraysstrings
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now