defaultdict(<type 'list'>, {'003': [('Biology', 'A', '04/18/2013'), ('Irdu', 'A'
, '04/17/2013')], '002': [('Biology', 'A', '03/01/2013'), ('Math', 'C', '01/10/2
013'), ('Math', 'C', '03/10/2013')], '001': [('Biology', 'B', '05/01/2013'), ('L
iterature', 'B', '03/02/2013'), ('Math', 'A', '02/20/2013')]})
我想按日期对每个键进行排序并获得以下输出
defaultdict(<type 'list'>, {'003': [('Irdu', 'A', '04/17/2013'), ('Biology', 'A', '04/18/2013')], '002': [('Math', 'C', '01/10/2013'), ('Biology', 'A', '03/01/2013'), ('Math', 'C', '03/10/2013')], '001': [('Math', 'A', '02/20/2013'), ('Literature', 'B', '03/02/2013'), ('Biology', 'B', '05/01/2013')]})
我尝试了以下但没有任何想法?
accounts = defaultdict(list)
sortedData = sorted(accounts.iteritems(), key=operator.itemgetter(2))