Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'omit': 0.07; 'callback': 0.09; 'here?': 0.09; 'cc:addr:python-list': 0.10; 'cmp': 0.16; 'subject:effect': 0.16; 'supplying': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'explicit': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'subject:what': 0.29; 'print': 0.32; 'function.': 0.33; 'code:': 0.33; 'subject:?': 0.35; 'being': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'subject:here': 0.84 Date: Tue, 10 Jul 2012 11:11:45 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: levi nie Subject: Re: what's the effect of cmp here? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:rmKcxR5W+4ypbM1SRAEYgpI2cUn0rSMiF3bb2BImbNT EbhJTeGehuNVXEdRyUmFgWevms4QUhNz3UoC3j25/9f+YkD8sz A0NvvKFYqZ4uhA+9i7rZrJZt4RYNXg64gpmrIm0qQhjTZ2kXVN +woei6kiCCNvuiyETkbEYLbiYr8uJN8VbUtao1Y2YVQndIh8wS ZrpzTvKg8l21/HAsZqDh6b41FVQr/8qgptd+d0s5iefbbm8dPr gZyqpJ/acpDtm3pkPPDhHA9eZwNTAJLEQG37RJ0Ovwsk2QCX3B p6WxHTGZHHVyM/YMc9YTb28GyA1+9yEEDegWpr6FQN+fH9IRg= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341933140 news.xs4all.nl 6935 [2001:888:2000:d::a6]:54907 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25133 On 07/10/2012 11:01 AM, levi nie wrote: > what's the effect of cmp here? The bList and cList is the same at last. > > code: > aList=[3,2,5,4] > > bList=aList[:] > bList.sort() > print "bList is",bList > > cList=aList[:] > cList.sort(cmp) > print "cList is",cList > > The main effect is for the reader of the code. When you supply your own callback to sort(), you're being explicit about how you want the items to be compared. If the default works for you, then you can omit supplying a function. -- DaveA