Re: [Tutor] to sort

2008-12-26 Thread Kent Johnson
On Fri, Dec 26, 2008 at 1:21 AM, prasad rao wrote: > By the way how can I view the builtin code for sort method? Look at the source - Objects/listobject.c - starting at the comment "Lots of code for an adaptive, stable, natural mergesort." http://svn.python.org/view/python/trunk/Objects/listobje

Re: [Tutor] to sort

2008-12-26 Thread Alan Gauld
"prasad rao" wrote a=[21,56,35,47,94,12] b=[] for x in a: b.append (min(a)) a.remove (min(a)) It is not Compleating .Doing only 3 rounds.Why? Think about what is happening. for x in a x takes the next value of x after each iteration. Each iteration reduces the size of a so a

Re: [Tutor] to sort

2008-12-25 Thread Mark Tolonen
"prasad rao" wrote in message news:9e3fac840812252221pe3345bam7e3e3563e050c...@mail.gmail.com... hello I am trying to sort a list(I know there is a builtin sort method). a=[21,56,35,47,94,12] b=[] for x in a: b.append (min(a)) a.remove (min(a)) >>> a [56, 47, 94] >>> b

[Tutor] to sort

2008-12-25 Thread prasad rao
hello I am trying to sort a list(I know there is a builtin sort method). a=[21,56,35,47,94,12] b=[] for x in a: b.append (min(a)) a.remove (min(a)) >>> a [56, 47, 94] >>> b [12, 21, 35] It is not Compleating .Doing only 3 rounds.Why? By the way how can I view the builtin code