Sorting lists
Your food delivery platform is expanding as new restaurants join daily. You have a restaurants list with restaurant names and a cooking_times list showing average meal preparation times in minutes. Your team needs both lists sorted to identify top-performing restaurants and improve delivery logistics.
Let's use another built-in function to handle this request.
Bu egzersiz
Intermediate Python for Developers
kursunun bir parçasıdırEgzersiz talimatları
- Sort
restaurantsalphabetically, saving asrestaurants_sorted. - Sort
cooking_timesfrom fastest to slowest, saving ascooking_times_sorted.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
restaurants = ["Sushi Central", "Burger Hub", "Taco Town", "Pizza Palace"]
cooking_times = [30, 25, 35, 40, 28, 32, 29, 31, 12, 55]
# Sort restaurant names alphabetically
restaurants_sorted = ____(____)
# Sort cooking times from fastest to slowest
cooking_times_sorted = ____(____)
print("Restaurants (A–Z):", restaurants_sorted)
print("Cooking times (ascending):", cooking_times_sorted)