Skip to content

Commit 2c462b1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0bcdd37 commit 2c462b1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sorts/sleep_sort.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import threading
22
import time
33

4+
45
def sleep_sort(arr):
56
"""
67
Sorts a list of positive integers using Sleep Sort.
7-
8+
89
Args:
910
arr (list[int]): List of positive integers to sort.
10-
11+
1112
Returns:
1213
list[int]: Sorted list in ascending order.
1314
"""
@@ -19,17 +20,18 @@ def sleeper(x):
1920
result.append(x)
2021

2122
threads = [threading.Thread(target=sleeper, args=(num,)) for num in arr]
22-
23+
2324
# Start all threads
2425
for t in threads:
2526
t.start()
26-
27+
2728
# Wait for all threads to finish
2829
for t in threads:
2930
t.join()
3031

3132
return result
3233

34+
3335
# Example Usage
3436
if __name__ == "__main__":
3537
numbers = [4, 1, 3, 2]

0 commit comments

Comments
 (0)