IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate Python for Developers

Visualizza il corso

Istruzioni dell'esercizio

  • Sort restaurants alphabetically, saving as restaurants_sorted.
  • Sort cooking_times from fastest to slowest, saving as cooking_times_sorted.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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)
Modifica ed esegui il codice