How do I sort a list of date and/or datetime objects? The accepted answer here isn't working for me:
from datetime import datetime,date,timedelta
a=[date.today(), date.today() + timedelta(days=1), date.today() - timedelta(days=1)]
print a # prints '[datetime.date(2013, 1, 22), datetime.date(2013, 1, 23), datetime.date(2013, 1, 21)]'
a = a.sort()
print a # prints 'None'....what???
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…