help how to sort a list in order of 'n' in python without using inbuilt functions??

Roy Smith roy at panix.com
Sat May 25 09:29:57 EDT 2013


In article <78192328-b31b-49d9-9cd6-ec742c092a29 at googlegroups.com>,
 lokeshkoppaka at gmail.com wrote:

> On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh... at gmail.com wrote:
> > i need to write a code which can sort the list in order of 'n' without use 
> > builtin functions 
> > 
> > can anyone help me how to do?
> 
>  Note:
> the list only contains 0's,1's,2's
> need to sort them in order of 'n'

What do you mean by "need to sort them in order of 'n'".  Are you saying 
that you need to sort them into numerical order?  Or that you need to 
running time of the algorithm to be O(n)?

I'm assuming the later, in which case this is starting to sound like a 
classic interview question.

Assuming you can accept an unstable sort, there's an easy solution.  I'm 
not aware of any solution if you require a stable sort.  Perhaps that's 
enough of a hint?



More information about the Python-list mailing list