diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-04-17 00:49:33 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-04-17 00:49:33 +0300 |
commit | 2183f3f860af34e45058ef078045322062b51f42 (patch) | |
tree | 1f61c51be301db314720fe4a945d6ddaaffa8249 /quicksort.py | |
parent | README update (diff) | |
download | sorting-algorithms-2183f3f860af34e45058ef078045322062b51f42.tar.gz sorting-algorithms-2183f3f860af34e45058ef078045322062b51f42.zip |
rearrange source files
* Add a useful `algorithms` package to provide convinient access to the
implemented algorithms.
* This allows to e.g. dynamically list available algorithms, which
greatly simplifies a lot of things.
Diffstat (limited to '')
-rw-r--r-- | algorithms/impl/quicksort.py (renamed from quicksort.py) | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/quicksort.py b/algorithms/impl/quicksort.py index b8ecc18..32100b0 100644 --- a/quicksort.py +++ b/algorithms/impl/quicksort.py @@ -63,3 +63,12 @@ if __name__ == '__main__': print(quicksort_middle(list(xs))) print(quicksort_last(list(xs))) print(quicksort_random(list(xs))) +else: + from algorithms.algorithm import SortingAlgorithm + _ALGORITHMS = [ + SortingAlgorithm('quicksort_first', 'Quicksort (first element as pivot)', quicksort_first), + SortingAlgorithm('quicksort_second', 'Quicksort (second element as pivot)', quicksort_second), + SortingAlgorithm('quicksort_middle', 'Quicksort (middle element as pivot)', quicksort_middle), + SortingAlgorithm('quicksort_last', 'Quicksort (last element as pivot)', quicksort_last), + SortingAlgorithm('quicksort_random', 'Quicksort (random element as pivot)', quicksort_random), + ] |