Sorting algorithms/Quicksort: Difference between revisions

Content added Content deleted
imported>Rcmlz
imported>Rcmlz
Line 8,271: Line 8,271:
<syntaxhighlight lang="raku" line>
<syntaxhighlight lang="raku" line>
#| Recursive, single-thread, random pivot, single-pass, quicksort implementation
#| Recursive, single-thread, random pivot, single-pass, quicksort implementation
sub quicksort(\a) {
multi quicksort(\a where a.elems < 2) { a }
multi quicksort(\a, \pivot = a.pick) {
return a if a.elems < 2;
my \pivot = a.pick;
my %prt{Order} is default([]) = a.classify: * cmp pivot;
my %prt{Order} is default([]) = a.classify: * cmp pivot;
|samewith(%prt{Less}), |%prt{Same}, |samewith(%prt{More})
|samewith(%prt{Less}), |%prt{Same}, |samewith(%prt{More})