Using Python 3.4, I am trying to sort a dictionary with two identical entries. When I run,
my_dict = {
'6/18/2015': [6, 'a'],
'6/19/2015': [18, 't'],
'6/17/2015': [3, 'r']
}
for key, value in sorted(my_dict.iteritems(), key=lambda kvt: kvt[1][0]):
print key, ':', value
I get a nicely printed result.
But when I use my actual data, which look more like:
my_dict = {
'6/18/2015': [6, 'a'],
'6/19/2015': [18, 't'],
'6/18/2015': [3, 'r'] #note the duplicate date
}
for key, value in sorted(my_dict.iteritems(), key=lambda kvt: kvt[1][0]):
print key, ':', value
the result just drops any repeated rows.
What am I doing wrong?
(Edited to add: thanks all for helping. Correct answer understood. In case anyone else has this problem, my dictionary's keys were actually tuples. Multiple tuples began with the same value and this confused me)