I'm having trouble sorting my dictionary
alphabetically by its keys
.
Here's my code:
colorSizes = {'Rust': ['SIZE 8', 'SIZE 10', 'SIZE 12', 'SIZE 14', 'SIZE 16', 'SIZE 18'],
'Middle Blue': ['SIZE 8', 'SIZE 10', 'SIZE 12', 'SIZE 14', 'SIZE 16', 'SIZE 18'],
'Grey': ['SIZE 8', 'SIZE 10', 'SIZE 12', 'SIZE 14', 'SIZE 16', 'SIZE 18'],
'Aqua': ['SIZE 8', 'SIZE 10', 'SIZE 12', 'SIZE 14', 'SIZE 16', 'SIZE 18'],
'Navy': ['SIZE 8', 'SIZE 10', 'SIZE 12', 'SIZE 14', 'SIZE 16']}
realColor = {}
for key in sorted(colorSizes.keys()):
realColor[key] = colorSizes.get(key)
print(realColor)
What I get:
{'Yellow/Fuschia':['Large', 'Extra Large'], 'Black':['Small', 'Medium', 'Large']}
What I wanna get:
{'Black':['Small', 'Medium', 'Large'], 'Yellow/Fuschia':['Large', 'Extra Large']}
Thanks!