Question bank › Sorting
Dsa Sorting Easy

Book Release Sorting

You are given a list of book releases represented by their titles and release dates in the format 'YYYY-MM-DD'. Your task is to sort the books by their release dates in ascending order. If two books have the same release date, sort them alphabetically by title. Input: The first line contains an integer N (1 ≤ N ≤ 100) — the number of books. The next N lines each contain a string (title, 1 ≤ len(title) ≤ 100) followed by a date (release date). Output: Print the sorted list of books in the format [[title1, date1], [title2, date2], ...]. Example: Input: 3 Book A 2023-01-01 Book B 2023-01-01 Book C 2023-02-01 Output: [[Book A, 2023-01-01], [Book B, 2023-01-01], [Book C, 2023-02-01]]

Key concepts

sortingdatesstrings

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.