Dsa
Sorting
Easy
Warehouse Restock Priority
An e-commerce warehouse needs to restock items. You are given a list of items with their current stock levels and their unit price. Sort the items for the restocking team based on these rules:
1. Items with lower stock levels come first.
2. If stock levels are equal, the item with the higher unit price comes first (higher value risk).
3. If both are equal, sort alphabetically by item name.
Input Format:
- An integer N.
- N lines: 'ItemName StockLevel Price'.
Output Format:
- The sorted ItemNames, space-separated on one line.
Example:
Input:
3
Bolts 50 0.10
Gears 10 5.50
Valves 10 12.00
Output:
Valves Gears Bolts
Key concepts
custom sort keysnumerical sorting
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