Created
January 8, 2021 19:16
-
-
Save mdnurahmed/899b2a192fa3c9825436fa132b11fdce to your computer and use it in GitHub Desktop.
Sorting by date
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
from datetime import datetime | |
def sortKey(val): | |
date = val[0] | |
#https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior | |
return datetime.strptime(date, '%m/%d/%Y') | |
mylist = list(mydict.items()) | |
mylist.sort(key = sortKey) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment