Python/sorts
Akash_Jambulkar 69f7f3208e
Update cocktail_shaker_sort.py (#10987)
* Update cocktail_shaker_sort.py

Added a docstring with clear explanations of the function and its parameters.

Changed variable names i, start, and end for better readability.

Improved comments to describe the purpose of each section of the algorithm.

Adjusted the loop ranges to make the code more concise and readable.

Removed redundant comments and variable assignments.

Provided a clear message when printing the sorted list.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update cocktail_shaker_sort.py

* typing: ignore[operator]

* Update cocktail_shaker_sort.py

* Update cocktail_shaker_sort.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-26 14:27:31 +02:00
..
__init__.py Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
bead_sort.py refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
binary_insertion_sort.py Code enhancements in binary_insertion_sort.py (#10918) 2023-10-24 23:51:04 +02:00
bitonic_sort.py Remove useless code in doctests (#7733) 2022-10-27 22:52:00 +02:00
bogo_sort.py Update bogo_sort.py (#8144) 2023-02-20 11:14:01 +13:00
bubble_sort.py Consolidate bubble sort iterative and recursive (#10651) 2023-10-19 22:45:51 +02:00
bucket_sort.py Fix sorts/bucket_sort.py implementation (#5786) 2023-08-17 18:38:19 -07:00
circle_sort.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
cocktail_shaker_sort.py Update cocktail_shaker_sort.py (#10987) 2023-10-26 14:27:31 +02:00
comb_sort.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30
counting_sort.py [pre-commit.ci] pre-commit autoupdate (#9013) 2023-08-29 15:18:10 +02:00
cycle_sort.py [pre-commit.ci] pre-commit autoupdate (#9013) 2023-08-29 15:18:10 +02:00
double_sort.py code enhancement in sort.double_sort (#10798) 2023-10-23 09:51:27 +02:00
dutch_national_flag_sort.py Add more ruff rules (#8767) 2023-05-26 09:34:17 +02:00
exchange_sort.py Create exchange_sort.py (#4600) 2021-08-15 07:43:05 +02:00
external_sort.py Replace bandit, flake8, isort, and pyupgrade with ruff (#8178) 2023-03-15 13:58:25 +01:00
gnome_sort.py Gnome sort : type hints, docstrings, doctests (#2307) 2020-08-14 22:00:08 +02:00
heap_sort.py contribution guidelines checks (#1787) 2020-03-04 13:40:28 +01:00
insertion_sort.py fixes #9002; improve insertion_sort algorithm (#9005) 2023-08-21 16:17:02 -07:00
intro_sort.py Create intro_sort.py (#3877) 2020-11-25 09:54:31 +01:00
iterative_merge_sort.py Fix iter_merge_sort bug (#6153) 2022-05-21 22:02:53 +08:00
merge_insertion_sort.py Reduce the complexity of sorts/merge_insertion_sort.py (#7954) 2022-12-24 15:57:28 +01:00
merge_sort.py Code Enhancements in merge_sort.py (#10911) 2023-10-25 17:26:54 -04:00
msd_radix_sort.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
natural_sort.py Create natural_sort.py (#3286) 2020-10-15 13:45:17 +02:00
normal_distribution_quick_sort.md Remove useless code in doctests (#7733) 2022-10-27 22:52:00 +02:00
odd_even_sort.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30
odd_even_transposition_parallel.py [pre-commit.ci] pre-commit autoupdate (#9013) 2023-08-29 15:18:10 +02:00
odd_even_transposition_single_threaded.py Fix word typos in comments (#4928) 2021-10-04 12:07:58 +08:00
pancake_sort.py contribution guidelines checks (#1787) 2020-03-04 13:40:28 +01:00
patience_sort.py fix: comment in patience sort (#4972) 2021-10-04 11:33:42 +08:00
pigeon_sort.py Pyupgrade to Python 3.9 (#4718) 2021-09-07 13:37:03 +02:00
pigeonhole_sort.py Create codespell.yml (#1698) 2020-01-18 13:24:33 +01:00
quick_sort_3_partition.py Quick sort with lomuto partition (#3875) 2021-02-17 15:28:50 +01:00
quick_sort.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
radix_sort.py refactor: Move constants outside of variable scope (#7262) 2022-10-16 15:03:29 +05:30
README.md Fix typos (#9076) 2023-09-23 10:53:09 +02:00
recursive_insertion_sort.py Remove useless code in doctests (#7733) 2022-10-27 22:52:00 +02:00
recursive_mergesort_array.py fix: use += in sorts/recursive_mergesort_array.py (#5019) 2021-10-27 00:43:46 +08:00
recursive_quick_sort.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
selection_sort.py Updated Selection Sort (#10855) 2023-10-23 14:12:28 -04:00
shell_sort.py Add typing (#9652) 2023-10-03 22:06:52 -04:00
shrink_shell_sort.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30
slowsort.py Pyupgrade to Python 3.9 (#4718) 2021-09-07 13:37:03 +02:00
stooge_sort.py Add typing (#9651) 2023-10-03 22:05:47 -04:00
strand_sort.py fix: no implicit optional (#7984) 2022-11-15 14:55:14 +01:00
tim_sort.py Make some ruff fixes (#8154) 2023-03-01 17:23:33 +01:00
topological_sort.py Add typing to topological_sort.py (#9650) 2023-10-03 21:47:03 -04:00
tree_sort.py Tree_sort.py: Disable slow doctest (#10584) 2023-10-16 10:17:48 -04:00
unknown_sort.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
wiggle_sort.py Wiggle sort (#2419) 2020-09-25 09:18:00 +02:00

Sorting Algorithms

Sorting is the process of putting data in a specific order. The way to arrange data in a specific order is specified by the sorting algorithm. The most typical orders are lexical or numerical. The significance of sorting lies in the fact that, if data is stored in a sorted manner, data searching can be highly optimised. Another use for sorting is to represent data in a more readable manner.

This section contains a lot of important algorithms that help us to use sorting algorithms in various scenarios.

References