@jerrold_langworth Вы можете использовать метод .sorted() для сортировки словаря по алфавиту.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
costs = { "Banana" : 10, "Apple" : 7, "Orange" : 9, "Blueberries" : 14, "Kiwi" : 12 } sorted_costs = dict() sorted_array = sorted(costs.items()) for cost in sorted_array: sorted_costs[cost[0]] = cost[1] print(sorted_costs) # Вывод : {'Apple': 7, 'Banana': 10, 'Blueberries': 14, 'Kiwi': 12, 'Orange': 9} |