在python字典中排序日期列表

时间:2014-11-27 16:35:30

标签: python sorting

我想弄清楚如何在python字典中对日期列表进行排序。例如,如果我在字典中有日期和名称,如下所示:

John 11/09/1998
Tom 02/01/1995
Steve 07/01/1988
Mike 12/12/2001

我希望它们排序,以便最近的日期是第一个,最早的日期是最后一个,即

Mike 12/12/2001 # this will be first
Steve 07/01/1988 # this will be last in my above example.

从我使用下面的代码阅读的内容是如何实现它的方式。你们中的任何人都有一个例子吗?

sorted(dictionary.items(), key=operator.itemgetter(1), reverse=False)

0 个答案:

没有答案