Sorting algorithms/Quicksort: Difference between revisions
Content added Content deleted
Line 262: | Line 262: | ||
a = quickSort(a) |
a = quickSort(a) |
||
In a Haskell fashion: |
In a Haskell fashion: |
||
import random |
|||
def qsort(L): |
def qsort(L): |
||
if len(L) <= 1: return L |
if len(L) <= 1: return L |
||
pivot = |
pivot, L = L[0], L[1:] |
||
return qsort([ |
return qsort([y for y in L if y <= pivot]) + [pivot] + \ |
||
qsort([ |
qsort([y for y in L if y > pivot]) |
||
=={{header|Seed7}}== |
=={{header|Seed7}}== |