Question bank › Strings
Dsa Strings Easy

Task Priority Sorter

You are given a list of tasks represented as strings where each task is formatted as 'priority:task_name'. The priority is a single uppercase letter (A-Z), where 'A' is the highest priority and 'Z' is the lowest. Write a program that sorts these tasks by their priority in ascending order (highest priority tasks should come first). Each task should be printed on a new line in sorted order. If two tasks have the same priority, they should retain their relative order from the input. Example Input: B:Send email A:Review code C:Update documentation Example Output: A:Review code B:Send email C:Update documentation

Key concepts

stringssortingpriority

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.