aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bubble_sort.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-04-17 00:49:33 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-04-17 00:49:33 +0300
commit2183f3f860af34e45058ef078045322062b51f42 (patch)
tree1f61c51be301db314720fe4a945d6ddaaffa8249 /bubble_sort.py
parentREADME update (diff)
downloadsorting-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/bubble_sort.py (renamed from bubble_sort.py)6
1 files changed, 6 insertions, 0 deletions
diff --git a/bubble_sort.py b/algorithms/impl/bubble_sort.py
index 8309201..2abfc43 100644
--- a/bubble_sort.py
+++ b/algorithms/impl/bubble_sort.py
@@ -31,3 +31,9 @@ if __name__ == '__main__':
xs = list(map(int, sys.argv[1:]))
print(bubble_sort(list(xs)))
print(bubble_sort_optimized(list(xs)))
+else:
+ from algorithms.algorithm import SortingAlgorithm
+ _ALGORITHMS = [
+ SortingAlgorithm('bubble_sort', 'Bubble sort', bubble_sort),
+ SortingAlgorithm('bubble_sort_optimized', 'Bubble sort (optimized)', bubble_sort_optimized),
+ ]