Sorting dictionary by datetime value
ikorot01 at gmail.com
Sat Feb 8 09:35:28 CET 2014
Thank you. That worked.
And no, I didn't notice that change. :(
On Sat, Feb 8, 2014 at 12:29 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot <ikorot01 at gmail.com> wrote:
> >> Try this:
> >> sorted_items = sorted(my_dict.keys(), key=my_dict.get)
> >> for key in sorted_items:
> >> print my_dict[key], key
> > This code fail.
> > sorted_item is a list of tuples. And so iterating the list in the for
> loop I
> > will get a tuple.
> > It probably should be:
> > for key in sorted_items:
> > Let me try that.
> Actually, it's a list of keys - notice that I changed my_dict.items()
> into my_dict.keys()?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list