We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
2 parents 94a3099 + e823c55 commit 1a434ddCopy full SHA for 1a434dd
sorts/radix_sort.py
@@ -0,0 +1,27 @@
1
+def radixsort(lst):
2
+ RADIX = 10
3
+ maxLength = False
4
+ tmp , placement = -1, 1
5
+
6
+ while not maxLength:
7
+ maxLength = True
8
+ # declare and initialize buckets
9
+ buckets = [list() for _ in range( RADIX )]
10
11
+ # split lst between lists
12
+ for i in lst:
13
+ tmp = i / placement
14
+ buckets[tmp % RADIX].append( i )
15
+ if maxLength and tmp > 0:
16
17
18
+ # empty lists into lst array
19
+ a = 0
20
+ for b in range( RADIX ):
21
+ buck = buckets[b]
22
+ for i in buck:
23
+ lst[a] = i
24
+ a += 1
25
26
+ # move to next
27
+ placement *= RADIX
0 commit comments