This notebook was prepared by Donne Martin. Source and license info is on GitHub.
Refer to the Solution Notebook. If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start.
class RadixSort(object):
def sort(self, array, base=10):
# TODO: Implement me
pass
The following unit test is expected to fail until you solve the challenge.
# %load test_radix_sort.py
import unittest
class TestRadixSort(unittest.TestCase):
def test_sort(self):
radix_sort = RadixSort()
self.assertRaises(TypeError, radix_sort.sort, None)
self.assertEqual(radix_sort.sort([]), [])
array = [128, 256, 164, 8, 2, 148, 212, 242, 244]
expected = [2, 8, 128, 148, 164, 212, 242, 244, 256]
self.assertEqual(radix_sort.sort(array), expected)
print('Success: test_sort')
def main():
test = TestRadixSort()
test.test_sort()
if __name__ == '__main__':
main()
Review the Solution Notebook for a discussion on algorithms and code solutions.