Question bank › Sorting
Dsa Sorting Easy

Academic Registry Cataloging

A university catalogs courses using a code format: 'DEPT-YEAR-ID' (e.g., CS-2023-101). You must sort a list of these codes to build an archive. 1. Sort alphabetically by Department (DEPT). 2. For the same department, sort by Year in descending order (newest first). 3. For the same department and year, sort by the numeric ID in ascending order. Input Format: - An integer N. - N strings in 'DEPT-YEAR-ID' format. Output Format: - The sorted codes, one per line. Example: Input: 3 BIO-2020-400 CS-2022-101 CS-2021-202 Output: BIO-2020-400 CS-2022-101 CS-2021-202

Key concepts

string splittingcomposite keys

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