Sorting algorithms/Quicksort: Difference between revisions
Content added Content deleted
(Updated first D entry) |
m (added FunL) |
||
Line 1,578:
A discussion about Quicksort pivot options, free source code for an optimized quicksort using insertion sort as a finisher, and an OpenMP multi-threaded quicksort is found at [http://balfortran.org balfortran.org]
=={{header|FunL}}==
<lang funl>def
qsort( [] ) = []
qsort( p:xs ) = qsort( xs.filter((< p)
Here is a more efficient version using the <code>partition</code> function.
<lang funl>
qsort( [] ) = []
qsort( x:xs ) =
val (ys, zs) = xs.partition( (< x)
qsort( ys ) + (x : qsort( zs ))
println( qsort([4, 2, 1, 3, 0, 2]) )
println( qsort(["
{{out}}
Line 1,608 ⟶ 1,599:
<pre>
[0, 1, 2, 2, 3, 4]
[
</pre>
|