Created
October 1, 2018 18:05
-
-
Save ardenn/97689589533220c336bad5ac0cfd65f1 to your computer and use it in GitHub Desktop.
Python Dictionaries Tutorial - sorting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('jobs.csv','r') as csv_file: | |
reader = csv.DictReader(csv_file) | |
for job in reader: | |
# Using sorted() to sort a dictionary's items on the keys | |
for key,val in sorted(job.items(),key=lambda item:item[0]): | |
# Apply any additional processing | |
print(key, val) #print the keys and values of each job |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment