Sorting a List of Fruits by Name and Length
📖 Scenario: You work in a fruit store and want to organize your list of fruits. Sometimes you want to see them in alphabetical order, and other times by how long their names are.
🎯 Goal: Learn how to use sorted() to sort a list alphabetically and sortedBy() to sort by a specific property, like the length of the fruit names.
📋 What You'll Learn
Create a list of fruits with exact names
Create a variable to hold the sorted list alphabetically
Create a variable to hold the list sorted by length of fruit names
Print both sorted lists exactly as specified
💡 Why This Matters
🌍 Real World
Sorting lists is common in apps like shopping lists, contact lists, or any place where you want to organize items for easier viewing.
💼 Career
Understanding sorting helps in data processing, UI display, and backend logic in many software development roles.
Progress0 / 4 steps