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: 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; '>>>': 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 To: fl Cc: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7bea4294e2b8b605178ed70e Content-Type: text/plain; charset=UTF-8 >>> 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] --047d7bea4294e2b8b605178ed70e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
>>> = ff=3Dsorted({1: 'D', 2: 'B', 3: 'B', 4: 'E'= , 5: 'A'})
>>> ff
[1= , 2, 3, 4, 5]
<= br>
sorted({1= : 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A= 9;}) is equivalent to=C2=A0
sorted(iter({1: 'D', 2: 'B', 3: 'B', 4: = 9;E', 5: 'A'}))

and iter(dict) iterates over the dict keys, so when you do
<= /span>iter({1: 'D', 2:= 'B', 3: 'B', 4: 'E', 5: 'A'}) you essentia= lly get [1,2,3,4,5]
=
and sorted([= 1,2,3,4,5]) returns [1,2,3,4,5]


--047d7bea4294e2b8b605178ed70e--