Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91893

Re: Please help on this sorted function

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <liik.joonas@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'keys,': 0.07; 'subject:help': 0.07; '[1,': 0.09; 'dict': 0.09; 'cc:addr:python-list': 0.10; '&gt;&gt;&gt;': 0.15; "'b',": 0.16; "'d',": 0.16; "'e',": 0.16; 'iterates': 0.16; '>>>': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'header:In-Reply- To:1': 0.24; 'equivalent': 0.27; 'message-id:@mail.gmail.com': 0.28; "skip:' 10": 0.30; 'received:google.com': 0.34; 'subject:: ': 0.37; 'subject:this': 0.85
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=v235XY0AC5XY3Rrfi6Rs4eTcp05/R3MuGHbQQ4ANnf4=; b=Kgt47StniF3IfW7JpsRCsumsIAmDdf9s6NJcZpu6b8jxCUP0xhxQRgKM2C15liPnzf sRlfej2rh0mmvQzGWlTxT3741HBqt8uzWR6UWiQdjNeyv1eh+1YICS0zjKd7cfNffbVE a0VvsIDjbpAE4KtGidrA4/NRtz4EkH8vVlEH1in9lekHT172EbsOVTcUgiKbKURXAeuv fGC082Ejhl2/mcI0888alfefzDAM1XvofM6DIP2NixzqO+yLDUO6Nd67rmps9KPSROvB hzDtwi0QQ5JxnKU7lFIO9aZbfz6i+CcmQ288lvbk0Oq9YI5oE75U0cvycg7jeiPf6bp/ f2ng==
MIME-Version 1.0
X-Received by 10.50.90.179 with SMTP id bx19mr22608921igb.43.1433277158305; Tue, 02 Jun 2015 13:32:38 -0700 (PDT)
In-Reply-To <37d9de72-b719-45a0-976c-441fc5898741@googlegroups.com>
References <37d9de72-b719-45a0-976c-441fc5898741@googlegroups.com>
Date Tue, 2 Jun 2015 23:32:38 +0300
Subject Re: Please help on this sorted function
From Joonas Liik <liik.joonas@gmail.com>
To fl <rxjwg98@gmail.com>
Cc Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7bea4294e2b8b605178ed70e
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.79.1433277166.13271.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1433277166 news.xs4all.nl 2871 [2001:888:2000:d::a6]:48339
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 4819
X-Received-Body-CRC 1771594116
Xref csiph.com comp.lang.python:91893

Show key headers only | View raw


[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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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