Dsa
Sorting
Warm-up
Sort Sandwich Ingredients
You are given a list of sandwich ingredients. Sort them based on the category: 'Condiments', 'Proteins', 'Vegetables'. Within each category, sort the ingredients alphabetically. Print the sorted ingredients, one per line.
Example Input:
Lettuce
Mustard
Turkey
Tomato
Mayo
Ham
Example Output:
Mayo
Mustard
Turkey
Ham
Lettuce
Tomato
Key concepts
sortingstringscustom-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