Created
March 16, 2016 13:43
-
-
Save victorono/e0c1ffb2cd694da53232 to your computer and use it in GitHub Desktop.
Sort list of date strings
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
all_dates = ['09-2012', '04-2007', '11-2012', '05-2013', '12-2006', '05-2006', '08-2007'] | |
sorted(all_dates, key=lambda x: datetime.strptime(x, '%m-%Y')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment