Sorting a set works, sorting a dictionary fails ?

Νικόλαος Κούρας nikos.gr33k at gmail.com
Mon Jun 10 04:18:30 EDT 2013


Τη Δευτέρα, 10 Ιουνίου 2013 11:16:37 π.μ. UTC+3, ο χρήστης Νικόλαος Κούρας έγραψε:
> What if i wanted to sort it out if alphabetically and not by the values?
> 
> 
> 
> Thsi worked:
> 
> 
> 
> for item in sorted(months.items(),key=lambda num : num[1]):
> 
> 
> 
> but this failed:
> 
> 
> 
> for item in sorted(months.items()):
> 
> 
> 
> why?

sorry what i was tryign to say was why not as: for item in sorted(months.values()):




More information about the Python-list mailing list