Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 | 1 def datesort(collection): |
2 from datetime import datetime | 2 return sorted(collection, reverse=True) |
3 | |
4 def datesort(collection, inputFormat='%Y-%m-%d', outputFormat='%B %d, %Y'): | |
5 if inputFormat != outputFormat: | |
6 for item in collection: | |
7 item[0] = datetime.strftime(datetime.strptime(item[0], inputFormat), outpu tFormat) | |
8 return sorted(collection, key=lambda date: datetime.strptime(date[0], outputFo rmat)) | |
saroyanm
2016/01/22 11:58:14
The items need to be sorted in descending order
juliandoucette
2016/01/25 16:19:55
Done.
| |
LEFT | RIGHT |