Skip to content

Commit

Permalink
add python implementation of slow sort algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
karasinski committed Oct 3, 2018
1 parent 88d5a4b commit 9f0c837
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sort/Slow_Sort/python/Slow_Sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def slowsort(A, i, j):
(i, j) = (int(i), int(j))
if i >= j:
return
m = (i + j) / 2
m = int(m)
slowsort(A, i, m)
slowsort(A, m + 1, j)
if A[m] > A[j]:
A[m], A[j] = A[j], A[m]
slowsort(A, i, j - 1)

test = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]
slowsort(test, 0, len(test) - 1)
print(test)
# >>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

0 comments on commit 9f0c837

Please sign in to comment.