Dsa
Sorting
Warm-up
System Log Severity Sort
A system administrator needs to sort log messages by severity. The severities are: 'ERROR' (highest priority), 'WARNING' (medium), and 'INFO' (lowest). Sort the logs by priority. If the priority is the same, sort by the Timestamp (integer, lower is earlier). If both are the same, sort by the message string.
Input: First line N. Next N lines: Severity Timestamp Message.
Output: The sorted messages.
Example Input:
3
INFO 100 UserLoggedIn
ERROR 50 DiskFull
WARNING 75 HighCPU
Example Output:
DiskFull
HighCPU
UserLoggedIn
Key concepts
sortingcustom priority
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