Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25133 > unrolled thread
| Started by | Dave Angel <d@davea.name> |
|---|---|
| First post | 2012-07-10 11:11 -0400 |
| Last post | 2012-07-10 11:11 -0400 |
| 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: what's the effect of cmp here? Dave Angel <d@davea.name> - 2012-07-10 11:11 -0400
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-07-10 11:11 -0400 |
| Subject | Re: what's the effect of cmp here? |
| Message-ID | <mailman.1986.1341933140.4697.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web