python - Sort dict alphabetically -


this question has answer here:

my program can output every student's name , 3 scores dict in file, need sort data alphabetical order. how can sort names , scores alphabetically according surname?

this code far: import pickle

def clssa():     filename="friendlist.data"     f=open('class6a.txt','rb')     storedlist = pickle.load(f)     key, value in storedlist.items():         sorted (key), value in storedlist.items()           print (("{} --> {}").format(key, value)) 

use sorted keyword.

for key, value in sorted(storedlist.items()):     # etc 

how sort dictionary key in numerical order python

https://wiki.python.org/moin/howto/sorting


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -