title: How to Radix Sort using Queues?
body: <p>How do you properly radix sort a list using queues?</p>
  
  <p>I'm using Python 3x.</p>
  
  <p>This is my attempt using queues as bins since queues are a first-in-first-out data structure.</p>
  
  <pre><code>from my_queue import Queue
  def rsort(n):
      '''(list of int) -&gt; list of int
      '''
      list_length = len(n)
      val = 0
      mod = 10
      k = 1
      bin_list = []
      alist = n
      for bins in range(0,10):
          bin_list.append(Queue())
  
      while val == 0:
          for num in alist:
              sig_dig = num % mod
              sig_dig = int(sig_dig / k)
              bin_list[sig_dig].enqueue(num)
  
          if bin_list[0].size() == list_length:
              alist.append(bin_list[0].dequeue())
  
          else:
              mod = mod * 10
              k = k * 10            
  
          new_list = []
          for bins in bin_list:
              if not bins.is_empty():
                  new_list.append(bins.dequeue())
              alist = new_list
  
          return alist
  </code></pre>
  
  <p>My code works perfectly fine with small numbers such as: <code>[3,2,6,5,8,7]</code></p>
  
  <p>but when values in the list become large like: <code>[240, 28, 5, 18, 140, 2]</code></p>
  
  <p>my program no longer sorts the list, numbers end up missing and unordered.</p>
  
  <p>I've been playing around with my program a lot but I just can't fix it :(</p>