From a8d3c2e51f0f8ab45c44ad0f20cb7c78c4bce68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20O=C4=9Fulcan=20Say=C4=B1n?= <47698920+iosayin@users.noreply.github.com> Date: Tue, 6 Oct 2026 22:01:09 +0300 Subject: [PATCH] refactor(sorts): add type annotations and doctests to pigeonhole_sort --- sorts/pigeonhole_sort.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sorts/pigeonhole_sort.py b/sorts/pigeonhole_sort.py index 70dc265917c7..c54b4adfac69 100644 --- a/sorts/pigeonhole_sort.py +++ b/sorts/pigeonhole_sort.py @@ -3,15 +3,25 @@ # Algorithm for the pigeonhole sorting -def pigeonhole_sort(a) -> None: +def pigeonhole_sort(a: list[int]) -> None: """ + Sort a list of integers destructively using pigeonhole sort. + >>> a = [8, 3, 2, 7, 4, 6, 8] >>> b = sorted(a) # a nondestructive sort >>> pigeonhole_sort(a) # a destructive sort >>> a == b True - >>> pigeonhole_sort([]) + >>> a = [-4, -1, -9, 0, 5, 2] + >>> pigeonhole_sort(a) + >>> a + [-9, -4, -1, 0, 2, 5] + + >>> a = [] + >>> pigeonhole_sort(a) + >>> a + [] """ if not a: return