Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
adding doctests for radix_sort.py
  • Loading branch information
mvhb committed Oct 4, 2020
commit 23f6f69a9e092866c7bb3289fd1e09842c2c9cd0
14 changes: 14 additions & 0 deletions Sorting/Radix_Sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
# digits of same place value. Then, sort the elements
# according to their increasing/decreasing order.

"""
For doctests run following command:
python -m doctest -v Radix_Sort.py
or
python3 -m doctest -v Radix_Sort.py
For manual testing run:
python Radix_Sort.py
"""

from math import log10
from random import randint

Expand All @@ -17,6 +26,11 @@ def prefix_sum(array):
return array

def radixsort(l, base=10):
"""
Examples:
>>> radixsort([0, 5, 3, 2, 2])
[0, 2, 2, 3, 5]
"""
passes = int(log10(max(l))+1)
output = [0] * len(l)

Expand Down