Question bank › Sorting
Dsa Sorting Easy

Online Store Product Sorter

You are tasked with sorting a list of products sold in an online store. Each product is described by a name and its price. You need to sort these products first by price in ascending order and then by name in alphabetical order if prices are the same. Input will be provided as multiple lines, each containing a product name and price separated by a comma. Output the sorted list of products in the same format, one per line. Example: Input: Laptop, 999.99 Mouse, 25.50 Keyboard, 45.00 Output: Mouse, 25.50 Keyboard, 45.00 Laptop, 999.99

Key concepts

sortingdictionaries

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.