Sorting algorithms/Stooge sort: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 226: | Line 226: | ||
after: -201 +0 +4 +9 +9 +67 +231 |
after: -201 +0 +4 +9 +9 +67 +231 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="arturo">innerStoogeSort: function [a, i, j][ |
|||
if a\[j] < a\[i] [ |
|||
t: a\[i] |
|||
a\[i]: a\[j] |
|||
a\[j]: t |
|||
] |
|||
if 1 < j - i [ |
|||
t: (1 + j - i) / 3 |
|||
innerStoogeSort a i j-t |
|||
innerStoogeSort a i+t j |
|||
innerStoogeSort a i j-t |
|||
] |
|||
] |
|||
stoogeSort: function [arr][ |
|||
result: new arr |
|||
innerStoogeSort result 0 dec size result |
|||
return result |
|||
] |
|||
print stoogeSort [3 1 2 8 5 7 9 4 6]</syntaxhighlight> |
|||
{{out}} |
|||
<pre>1 2 3 4 5 6 7 8 9</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |