Sorting algorithms/Stooge sort: Difference between revisions
Content deleted Content added
mNo edit summary |
→{{header|Yorick}}: added zkl |
||
Line 1,893: | Line 1,893: | ||
> foo |
> foo |
||
[-6,-5,-2,1,3,3,4,5,7,10]</pre> |
[-6,-5,-2,1,3,3,4,5,7,10]</pre> |
||
=={{header|zkl}}== |
|||
<lang zkl>fcn stoogeSort(list,i=0,j=Void){ if(Void==j) j=list.len() - 1; // default parameters set before call |
|||
if(list[j]<list[i]) list.swap(i,j); |
|||
if(j - i >1){ |
|||
t:=(j - i + 1)/3; |
|||
stoogeSort(list,i , j-t); |
|||
stoogeSort(list,i+t, j ); |
|||
stoogeSort(list,i , j-t); |
|||
} |
|||
list |
|||
}</lang> |
|||
<lang zkl>stoogeSort(List(67,-201,0,9,9,231,4)).println();</lang> |
|||
{{out}} |
|||
<pre> |
|||
L(-201,0,4,9,9,67,231) |
|||
</pre> |