Question bank › Sorting
Dsa Sorting Easy

Product Price Sorting

You run an online store and have a list of products along with their prices. Your task is to sort the products based on their prices in ascending order. If two products share the same price, sort them by name in alphabetical order. Print the sorted products in the format: 'ProductName: Price'. Input Format: - The first line contains an integer N (1 <= N <= 1000), the number of products. - The next N lines each contain the product name followed by its price. Output Format: - Print each product and its price in the sorted order. Example: Input: 3 Laptop 1500 Mouse 20 Keyboard 20 Output: Mouse: 20 Keyboard: 20 Laptop: 1500

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.