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
4 changes: 3 additions & 1 deletion sorts/pigeonhole_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def pigeonhole_sort(a):
>>> a == b
True
"""
if not a:
return # this handles empty list
# size of range of values in the list (ie, number of pigeonholes we need)

min_val = min(a) # min() finds the minimum value
Expand Down Expand Up @@ -38,7 +40,7 @@ def pigeonhole_sort(a):
def main():
a = [8, 3, 2, 7, 4, 6, 8]
pigeonhole_sort(a)
print("Sorted order is:", " ".join(a))
print("Sorted order is:", " ".join(map(str, a))) # it converts integer into string


if __name__ == "__main__":
Expand Down