Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#135 from KuLi/radix_sort-fix
Browse files Browse the repository at this point in the history
TheAlgorithms#130 fixed radix sort for python 3
  • Loading branch information
harshildarji authored Oct 17, 2017
2 parents 12a5b3a + edcf6d5 commit 54eb79f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sorts/radix_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ def radixsort(lst):
RADIX = 10
maxLength = False
tmp , placement = -1, 1

while not maxLength:
maxLength = True
# declare and initialize buckets
buckets = [list() for _ in range( RADIX )]

# split lst between lists
for i in lst:
tmp = i / placement
tmp = i // placement
buckets[tmp % RADIX].append( i )
if maxLength and tmp > 0:
maxLength = False

# empty lists into lst array
a = 0
for b in range( RADIX ):
buck = buckets[b]
for i in buck:
lst[a] = i
a += 1

# move to next
placement *= RADIX

0 comments on commit 54eb79f

Please sign in to comment.