def radixsort( aList ):
  RADIX = 2
  maxLength = False
  tmp , placement = -1, 1
 
  while not maxLength:
    maxLength = True
    # declare and initialize buckets
    buckets = [list() for _ in range( RADIX )]
 
    # split aList between lists
    for  i in aList:
      tmp = i / placement
      buckets[tmp % RADIX].append( i )
      if maxLength and tmp > 0:
        maxLength = False
 
    # empty lists into aList array
    a = 0
    for b in range( RADIX ):
      buck = buckets[b]
      for i in buck:
        aList[a] = i
        a += 1
 
    # move to next digit
    placement *= RADIX

# aList=[221,1,3,23,2]
# print aList
# radixsort(aList)
# print aList
import random
import time
a=time.time()
print "START",a
print radixsort([random.randrange(0,10000) for x in range(1000000)])
b=time.time()-a
print "TOTAL",b



def radixsort( aList ):
  RADIX = 2
  maxLength = False
  tmp , placement = -1, 1
 
  while not maxLength:
    maxLength = True
    # declare and initialize buckets
    buckets = [list() for _ in range( RADIX )]
 
    # split aList between lists
    for  i in aList:
      tmp = i / placement
      buckets[tmp % RADIX].append( i )
      if maxLength and tmp > 0:
        maxLength = False
 
    # empty lists into aList array
    a = 0
    for b in range( RADIX ):
      buck = buckets[b]
      for i in buck:
        aList[a] = i
        a += 1
 
    # move to next digit
    placement *= RADIX

# aList=[221,1,3,23,2]
# print aList
# radixsort(aList)
# print aList
import random
import time
a=time.time()
print "START",a
print radixsort([random.randrange(0,10000) for x in range(1000000)])
b=time.time()-a
print "TOTAL",b



# declare and initialize buckets # split aList between lists # empty lists into aList array # move to next digit # aList=[221,1,3,23,2] # print aList # radixsort(aList) # print aList