Skip to content

Added Code for Sleep Sort #6988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 26 additions & 0 deletions SleepSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from threading import Timer
from time import sleep


def sleep_sort(l):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: sleep_sort. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file SleepSort.py, please provide doctest for the function sleep_sort

Please provide type hint for the parameter: l

Please provide descriptive name for the parameter: l

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: sleep_sort. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file SleepSort.py, please provide doctest for the function sleep_sort

Please provide type hint for the parameter: l

Please provide descriptive name for the parameter: l

res = []

def add1(x):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: add1. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file SleepSort.py, please provide doctest for the function add1

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: add1. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file SleepSort.py, please provide doctest for the function add1

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

res.append(x)

mx = l[0]
for i in l:
if mx < i:
mx = i
Timer(i, add1, [i]).start()
sleep(mx + 1)
return res


l1 = [4, 1, 2, 8, 5]
print("Initial Array")
print(l1)

print("Final Array is Arriving! Please wait..")
r = sleep_sort(l1)
print(r)