-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide type hint for the parameter: Please provide descriptive name for the parameter: |
||
res = [] | ||
|
||
def add1(x): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide type hint for the parameter: Please provide descriptive name for the parameter: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide type hint for the parameter: Please provide descriptive name for the parameter: |
||
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) |
There was a problem hiding this comment.
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 functionsleep_sort
Please provide type hint for the parameter:
l
Please provide descriptive name for the parameter:
l