日期保存格式爲:2012-09-28。如何對列表進行排序,以便最近發佈的項目首先位於列表中?如何按日期對列表進行排序?
feed = []
for entry in entries:
#code that saves title, desc, thumbnail, video, author, url, length, and date
feed.append([title, desc, thumbnail, video, author, url, length, date ])
你得到我的投票注意到,它需要的是一個反向排序。 –
@MarkRansom謝謝:) –
如果您對'lambda'有反感,'operator.itemgetter(7)'也可以用於關鍵函數。 – mgilson