一尘不染

在python数组中排序日期

python

如何在python 2.4上对以下日期数组进行排序

 timestamps = ['2011-06-2', '2011-08-05', '2011-02-04', '2010-1-14', '2010-12-13', '2010-1-12', '2010-2-11', '2010-2-07', '2010-12-02', '2011-11-30', '2010-11-26', '2010-11-23', '2010-11-22', '2010-11-16']

阅读 185

收藏
2020-12-20

共1个答案

一尘不染

sorted(timestamps, key=lambda d: map(int, d.split('-')))
2020-12-20