summaryrefslogtreecommitdiff
path: root/progs/unparsable_programs/a879.py
blob: 791dd76eefedaa7559372354171a92770e75964a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def radix_sort(nums):
    RADIX = 10
    placement = 1
    max_digit = max(nums)

    while placement < max_digit:
      buckets = [list() for _ in range( RADIX )]
      for i in nums:
        tmp = int((i / placement) % RADIX)
        buckets[tmp].append(i)
      a = 0
      for b in range( RADIX ):
        buck = buckets[b]
        for i in buck:
          nums[a] = i
          a += 1
      placement *= RADIX
    return nums