sort dates in python array

后端 未结 9 2062
野的像风
野的像风 2020-11-27 19:39

How to sort the below array of dates on python 2.4

 timestamps = [\'2011-06-2\', \'2011-08-05\', \'2011-02-04\', \'2010-1-14\', \'2010-12-13\', \'2010-1-12\'         


        
9条回答
  •  粉色の甜心
    2020-11-27 20:14

    print(sorted(list_of_strings,key=lambda x :(int(x.split('-')[0]),int(x.split('-')[1]),int(x.split('-')[2])))
    

提交回复
热议问题