Jump to content

Sorting algorithms/Quicksort: Difference between revisions

(→‎{{header|BASIC}}: Added XBasic.)
Line 8,646:
_quicksort(array, start, right)
_quicksort(array, left, stop)</syntaxhighlight>
 
Functional Style (no for or while loops, constants only):
 
<syntaxhighlight lang="python">
def quicksort(unsorted_list):
if len(unsorted_list) == 0:
return ()
pivot = unsorted_list[0]
less = filter(lambda x: x < pivot, unsorted_list)
same = filter(lambda x: x == pivot, unsorted_list)
more = filter(lambda x: x > pivot, unsorted_list)
 
return quicksort(less) + same + quicksort(more)
</syntaxhighlight>
 
=={{header|Qi}}==
3

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.