From 80daa5750a8e5ee6ffcbcad72b2b52540d0b502d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E4=B9=88=E5=B0=8F=E5=84=BF=E9=83=8EEL?= Date: Tue, 1 Sep 2020 00:55:56 +0800 Subject: [PATCH] Fix bugs and add related tests (#2375) --- sorts/radix_sort.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sorts/radix_sort.py b/sorts/radix_sort.py index c379c6797..0ddf996cf 100644 --- a/sorts/radix_sort.py +++ b/sorts/radix_sort.py @@ -7,11 +7,13 @@ def radix_sort(list_of_ints: List[int]) -> List[int]: True radix_sort(reversed(range(15))) == sorted(range(15)) True + radix_sort([1,100,10,1000]) == sorted([1,100,10,1000]) + True """ RADIX = 10 placement = 1 max_digit = max(list_of_ints) - while placement < max_digit: + while placement <= max_digit: # declare and initialize empty buckets buckets = [list() for _ in range(RADIX)] # split list_of_ints between the buckets