Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65680 > unrolled thread
| Started by | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| First post | 2014-02-08 08:11 -0600 |
| Last post | 2014-02-08 08:11 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Sorting dictionary by datetime value Tim Chase <python.list@tim.thechases.com> - 2014-02-08 08:11 -0600
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2014-02-08 08:11 -0600 |
| Subject | Re: Sorting dictionary by datetime value |
| Message-ID | <mailman.6540.1391868679.18130.python-list@python.org> |
On 2014-02-08 19:29, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot <ikorot01@gmail.com> > wrote: > >> Try this: > >> > >> sorted_items = sorted(my_dict.keys(), key=my_dict.get) > > > > This code fail. > > Actually, it's a list of keys - notice that I changed > my_dict.items() into my_dict.keys()? Unless you need to make a copy (for purposes of altering the original while iterating), that's the default behavior of iterating over a dict, so it could be simplified to sorted_items = sorted(my_dict, key=my_dict.get) -tkc
Back to top | Article view | comp.lang.python
csiph-web