Jump to content

Sorting algorithms/Quicksort: Difference between revisions

→‎{{header|UnixPipes}}: slightly more parallel and hence faster
(→‎{{header|UnixPipes}}: slightly more parallel and hence faster)
Line 442:
 
=={{header|UnixPipes}}==
{{works with|Zsh}}
(a race condition seems to happen in bash when using cat -s instead of using the sequential print)
split() {
(pivot=$1; lc=$2; gc=$3;
Line 452 ⟶ 454:
lc="1.$1" ; gc="2.$1"
read pivot; test -n "$pivot" && (
split $pivot >(cat >> $lc) >( cat >> $gc);
cat -s <(cat -s $lc | qsort $lc ) <(echo $pivot;) <(cat -s $gc | qsort $gc )
)
rm -f $lc $gc;
418

edits

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