-
-
Notifications
You must be signed in to change notification settings - Fork 49.5k
feat: add sleep sort algorithm and complete bubble sort implementationfeat: add sleep sort and complete bubble sort #13632
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
feat: add sleep sort algorithm and complete bubble sort implementationfeat: add sleep sort and complete bubble sort #13632
Conversation
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
sorts/sleep_sort.py
Outdated
| result = [] | ||
| lock = threading.Lock() | ||
|
|
||
| def worker(value: int) -> None: |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function worker
sorts/sleep_sort.py
Outdated
| return result | ||
|
|
||
|
|
||
| def sleep_sort_simple(arr: List[int]) -> List[int]: |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function sleep_sort_simple
sorts/sleep_sort.py
Outdated
| pairs = [(value, i) for i, value in enumerate(arr)] | ||
|
|
||
| # Sort based on value | ||
| pairs.sort(key=lambda x: x[0]) |
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 descriptive name for the parameter: x
sorts/sleep_sort.py
Outdated
| A class-based implementation of sleep sort with additional features. | ||
| """ | ||
|
|
||
| def _init_(self, speed_factor: float = 10.0): |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function _init_
Please provide return type hint for the function: _init_. If the function does not return a value, please provide the type hint as: def function() -> None:
sorts/sleep_sort.py
Outdated
| """ | ||
| self.speed_factor = speed_factor | ||
|
|
||
| def sort(self, arr: List[int]) -> List[int]: |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function sort
sorts/sleep_sort.py
Outdated
| result = [] | ||
| lock = threading.Lock() | ||
|
|
||
| def worker(value: int) -> None: |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function worker
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
sorts/sleep_sort.py
Outdated
| from typing import List | ||
|
|
||
|
|
||
| def sleep_sort(arr: List[int]) -> List[int]: |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function sleep_sort
sorts/sleep_sort.py
Outdated
| result = [] | ||
| lock = threading.Lock() | ||
|
|
||
| def worker(value): |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function worker
Please provide return type hint for the function: worker. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
sorts/sleep_sort.py
Outdated
| class SleepSort: | ||
| """Class-based sleep sort implementation.""" | ||
|
|
||
| def _init_(self, speed_factor=10.0): |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function _init_
Please provide return type hint for the function: _init_. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: speed_factor
sorts/sleep_sort.py
Outdated
| def _init_(self, speed_factor=10.0): | ||
| self.speed_factor = speed_factor | ||
|
|
||
| def sort(self, arr): |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function sort
Please provide return type hint for the function: sort. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: arr
sorts/sleep_sort.py
Outdated
| result = [] | ||
| lock = threading.Lock() | ||
|
|
||
| def worker(value): |
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.
As there is no test file in this pull request nor any test function or class in the file sorts/sleep_sort.py, please provide doctest for the function worker
Please provide return type hint for the function: worker. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: value
for more information, see https://pre-commit.ci
- Add working sleep sort algorithm using threading - Include user input functionality - Tested with sample input [3,1,4,2] - works correctly
- Remove bubble_sort.py to focus on sleep sort implementation - Fix type hints: use built-in list instead of typing.List
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Hi maintainers! 👋 This PR adds sleep sort algorithm and completes bubble sort implementation. All CI checks have passed ✅ Could one of you please review when you have time? Thank you! |
Description
Types of changes
Checklist