I d like to ask you how to sort dictionary by keys...the task is:you have a string of words and you have to count how much words are there and how much times is there ...for example : Hi mom hi dad hi -> hi 3 mom 1 dad 1 ...this is where I ended with this code :
zoznam = {}
x= 1
string= input ("")
rozdel= string.split()
for i in range (len(rozdel)):
x = rozdel.count(rozdel[i])
zoznam[rozdel[i]] = x
print zoznam
..but now I have to sort that dictionary by keys (words) by first letter ..from example before -> dad 1 hi 3 mom 1 ...thank you :)