Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45974

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

From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
Subject RE: help how to sort a list in order of 'n' in python without using inbuilt functions??
Date 2013-05-25 10:53 +0300
References <74e33270-a79a-4878-a400-8a6cda6637b2@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2116.1369468467.3114.python-list@python.org> (permalink)

Show all headers | View raw


----------------------------------------
> Date: Fri, 24 May 2013 23:05:17 -0700
> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: lokeshkoppaka@gmail.com
> To: python-list@python.org
[...]
> ya steven i had done the similar logic but thats not satisfying my professor
> he had given the following constrains
> 1. No in-built functions should be used
> 2. we are expecting a O(n) solution
> 3. Don't use count method

That's trivial!

# l is a list of numbers: 0,1,2
def order_n(l):
    r = []
    count = [0]*3
    count[2] = len(l)
    for i in range(len(l)):
        count[1] += abs((l[i]>0)-1)
        r.insert(count[l[i]], l[i])
    return r

'count' is a list I've defined to count the quantity of the elements in the argument, not the method.

I don't think it needs any explanations, but if you have any doubts just ask. ;)

Good luck! 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 01:04 -0700
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-24 18:12 +1000
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-24 08:33 -0400
  RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 16:06 +0300
  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:15 -0700
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:24 +1000
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:39 -0700
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:43 +1000
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 05:57 +0000
          Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 23:05 -0700
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 16:12 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 10:53 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:28 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:43 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:47 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:54 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:01 +1000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:10 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:14 +1000
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:28 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Fábio Santos <fabiosantosart@gmail.com> - 2013-05-25 15:46 +0100
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 16:03 +0100
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 01:41 +1000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:09 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:02 +1000
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:12 +0300
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:17 +0300
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 03:23 +1000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:38 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dan Sommers <dan@tombstonezero.net> - 2013-05-26 04:06 +0000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:28 +1000
                RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:34 +0300
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:30 +0300
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 13:01 +0100
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 10:03 -0400
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-25 10:27 -0400
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:30 +0000
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:07 +0300
            RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:45 +0300
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? rusi <rustompmody@gmail.com> - 2013-05-24 22:43 -0700
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 09:29 -0400
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-25 17:59 +0300

csiph-web