Skip to content

Commit d568d6b

Browse files
committed
refactor(sorts): make odd_even_transposition_parallel sort any comparable items
1 parent 215c1f0 commit d568d6b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎sorts/odd_even_transposition_parallel.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
"""
1313

1414
import multiprocessing as mp
15+
from typing import Any, Protocol
16+
17+
18+
class Comparable(Protocol):
19+
def __lt__(self, other: Any, /) -> bool: ...
20+
1521

1622
# lock used to ensure that two processes do not access a pipe at the same time
1723
# NOTE This breaks testing on build runner. May work better locally
@@ -78,7 +84,7 @@ def oe_process(
7884
"""
7985

8086

81-
def odd_even_transposition(arr):
87+
def odd_even_transposition[T: Comparable](arr: list[T]) -> list[T]:
8288
"""
8389
>>> odd_even_transposition(list(range(10)[::-1])) == sorted(list(range(10)[::-1]))
8490
True

0 commit comments

Comments
 (0)