Repository: keon/algorithms
Pull request #313 (2018-06-06 06:21:25)

Created gnome sort in sort algorithm
Implemented Gnome sort, updated _ _init_ _.py and test_sort.py as well.

lg970325: Updated README files as well :)
goswami-rahul: I resolved the merge conflicts due to some other PR on these files

Patch:
diff --git a/README.md b/README.md
index bdfc343..f31075f 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ For running all tests write down:
 ## Install
 If you want to use the API algorithms in your code, it is as simple as:
 
-    $ pip3 install git+https://github.com/keon/algorithms
+    $ pip3 install algorithms
 
 You can test by creating a python file: (Ex: use `merge_sort` in `sort`)
 
@@ -228,6 +228,7 @@ If you want to uninstall algorithms, it is as simple as:
     - [cocktail_shaker_sort](algorithms/sort/cocktail_shaker_sort.py)
     - [comb_sort](algorithms/sort/comb_sort.py)
     - [counting_sort](algorithms/sort/counting_sort.py)
+    - [gnome_sort](algorithms/sort/gnome_sort.py)
     - [heap_sort](algorithms/sort/heap_sort.py)
     - [insertion_sort](algorithms/sort/insertion_sort.py)
     - [meeting_rooms](algorithms/sort/meeting_rooms.py)
diff --git a/README_CN.md b/README_CN.md
index 7f0abea..4e93822 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -212,6 +212,7 @@ pip3 uninstall -y algorithms
     - [cocktail_shaker_sort](algorithms/sort/cocktail_shaker_sort.py)
     - [comb_sort：梳排序](algorithms/sort/comb_sort.py)
     - [counting_sort：计数排序](algorithms/sort/counting_sort.py)
+    - [gnome_sort](algorithms/sort/gnome_sort.py)
     - [heap_sort：堆排序](algorithms/sort/heap_sort.py)
     - [insertion_sort：插入排序](algorithms/sort/insertion_sort.py)
     - [meeting_rooms：会议室](algorithms/sort/meeting_rooms.py)
diff --git a/README_GE.md b/README_GE.md
index f4de311..8bc1fd2 100644
--- a/README_GE.md
+++ b/README_GE.md
@@ -233,6 +233,7 @@ Um das Projekt zu deinstallieren tippen Sie folgendes:
     - [cocktail_shaker_sort](algorithms/sort/cocktail_shaker_sort.py)
     - [comb_sort](algorithms/sort/comb_sort.py)
     - [counting_sort](algorithms/sort/counting_sort.py)
+    - [gnome_sort](algorithms/sort/gnome_sort.py)
     - [heap_sort](algorithms/sort/heap_sort.py)
     - [insertion_sort](algorithms/sort/insertion_sort.py)
     - [meeting_rooms](algorithms/sort/meeting_rooms.py)
diff --git a/README_JP.md b/README_JP.md
index 1abcebe..0e63b9c 100644
--- a/README_JP.md
+++ b/README_JP.md
@@ -227,6 +227,7 @@ if __name__ == "__main__":
     - [cocktail_shaker_sort](algorithms/sort/cocktail_shaker_sort.py)
     - [comb_sort](algorithms/sort/comb_sort.py)
     - [counting_sort](algorithms/sort/counting_sort.py)
+    - [gnome_sort](algorithms/sort/gnome_sort.py)
     - [heap_sort](algorithms/sort/heap_sort.py)
     - [insertion_sort](algorithms/sort/insertion_sort.py)
     - [meeting_rooms](algorithms/sort/meeting_rooms.py)
diff --git a/README_KR.md b/README_KR.md
index 796af77..fde2147 100644
--- a/README_KR.md
+++ b/README_KR.md
@@ -223,6 +223,7 @@ if __name__ == "__main__":
     - [cocktail_shaker_sort](algorithms/sort/cocktail_shaker_sort.py)
     - [comb_sort](algorithms/sort/comb_sort.py)
     - [counting_sort](algorithms/sort/counting_sort.py)
+    - [gnome_sort](algorithms/sort/gnome_sort.py)
     - [heap_sort](algorithms/sort/heap_sort.py)
     - [insertion_sort](algorithms/sort/insertion_sort.py)
     - [meeting_rooms](algorithms/sort/meeting_rooms.py)
diff --git a/algorithms/sort/__init__.py b/algorithms/sort/__init__.py
index 27468e8..a2c6d3c 100644
--- a/algorithms/sort/__init__.py
+++ b/algorithms/sort/__init__.py
@@ -11,4 +11,5 @@ from .top_sort import *
 from .bucket_sort import *
 from .shell_sort import *
 from .radix_sort import *
+from .gnome_sort import *
 from .cocktail_shaker_sort import *
diff --git a/algorithms/sort/gnome_sort.py b/algorithms/sort/gnome_sort.py
new file mode 100644
index 0000000..aaf38a2
--- /dev/null
+++ b/algorithms/sort/gnome_sort.py
@@ -0,0 +1,19 @@
+"""
+
+Gnome Sort
+Best case performance is O(n)
+Worst case performance is O(n^2)
+
+"""
+
+
+def gnome_sort(arr):
+    n = len(arr)
+    index = 0
+    while index < n:
+        if index == 0 or arr[index] >= arr[index-1]:
+            index = index + 1
+        else:
+            arr[index], arr[index-1] = arr[index-1], arr[index]
+            index = index - 1
+    return arr
diff --git a/setup.py b/setup.py
index 1bb71d3..65a80c6 100644
--- a/setup.py
+++ b/setup.py
@@ -3,16 +3,26 @@ import io
 import re
 from setuptools import find_packages, setup
 
+
+def long_description():
+    with io.open('README.md', 'r', encoding='utf-8') as f:
+        readme = f.read()
+    return readme
+
+
 setup(name='algorithms',
-      version='1.1',
+      version='0.1.0',
       description='Pythonic Data Structures and Algorithms',
+      long_description=long_description(),
       url='https://github.com/keon/algorithms',
-      author='Keon Kim, Hai Hoang Dang, Rahul Goswami, Christian Bender, Saad',
+      author='Algorithms Team & Contributors',
+      author_email="kwk236@gmail.com",
       license='MIT',
       packages=find_packages(),
       classifiers=[
           'Programming Language :: Python :: 3',
           'Programming Language :: Python :: 3.4',
           'Programming Language :: Python :: 3.5',
+          'Programming Language :: Python :: 3.6',
           ],
       zip_safe=False)


Test patch:
diff --git a/tests/test_sort.py b/tests/test_sort.py
index ef8e754..020b9a3 100644
--- a/tests/test_sort.py
+++ b/tests/test_sort.py
@@ -11,7 +11,8 @@ from algorithms.sort import (
     bucket_sort,
     shell_sort,
     radix_sort,
-    cocktail_shaker_sort
+    gnome_sort,
+    cocktail_shaker_sort,
 )
 
 import unittest
@@ -69,7 +70,11 @@ class TestSuite(unittest.TestCase):
     def test_radix_sort(self):
         self.assertEqual([1, 5, 23, 57, 65, 1232],
                         radix_sort([1, 5, 65, 23, 57, 1232]))
-     
+    
+    def test_gnome_sort(self):
+        self.assertEqual([1, 5, 23, 57, 65, 1232],
+                         gnome_sort([1, 5, 65, 23, 57, 1232]))
+                                          
     def test_cocktail_shaker_sort(self):
         self.assertEqual([1, 5, 23, 57, 65, 1232],
                         cocktail_shaker_sort([1, 5, 65, 23, 57, 1232]))