Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91893
| References | <37d9de72-b719-45a0-976c-441fc5898741@googlegroups.com> |
|---|---|
| Date | 2015-06-02 23:32 +0300 |
| Subject | Re: Please help on this sorted function |
| From | Joonas Liik <liik.joonas@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.79.1433277166.13271.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
>>> ff=sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})
>>> ff
[1, 2, 3, 4, 5]
sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}) is equivalent to
sorted(iter({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}))
and iter(dict) iterates over the dict keys, so when you do
iter({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}) you essentially get
[1,2,3,4,5]
and sorted([1,2,3,4,5]) returns [1,2,3,4,5]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Please help on this sorted function fl <rxjwg98@gmail.com> - 2015-06-02 13:20 -0700
Re: Please help on this sorted function fl <rxjwg98@gmail.com> - 2015-06-02 13:25 -0700
Re: Please help on this sorted function Joonas Liik <liik.joonas@gmail.com> - 2015-06-02 23:42 +0300
Re: Please help on this sorted function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-03 18:21 +1000
Re: Please help on this sorted function Chris Angelico <rosuav@gmail.com> - 2015-06-03 10:01 +1000
Re: Please help on this sorted function Joonas Liik <liik.joonas@gmail.com> - 2015-06-02 23:32 +0300
Re: Please help on this sorted function Gary Herron <gherron@digipen.edu> - 2015-06-02 14:00 -0700
csiph-web