Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

Commit

Permalink
#21 added q-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
juliojesus1508 authored and yshshrm committed Oct 26, 2017
1 parent a64c1ea commit 980f3b2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/quicksort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

def quicksort(array=[12,4,5,6,7,3,1,15]):
less = []
equal = []
greater = []
if len(array) > 1:
pivot = array[0]
for x in array:
if x < pivot:
less.append(x)
if x == pivot:
equal.append(x)
if x > pivot:
greater.append(x)
return sort(less)+equal+sort(greater)
else:
return array

0 comments on commit 980f3b2

Please sign in to comment.