Sorting algorithms/Gnome sort: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 554: | Line 554: | ||
</lang> |
</lang> |
||
=={{header|Arturo}}== |
|||
<lang rebol>gnomeSort: function [items][ |
|||
i: 1 |
|||
j: 2 |
|||
arr: new items |
|||
while [i < size arr][ |
|||
if? (arr \ i-1) =< arr \ i [ |
|||
i: j |
|||
j: j + 1 |
|||
] |
|||
else [ |
|||
tmp: arr \ i |
|||
set arr i get arr i-1 |
|||
set arr i-1 tmp |
|||
i: i-1 |
|||
if i=0 [ |
|||
i: j |
|||
j: j + 1 |
|||
] |
|||
] |
|||
] |
|||
return arr |
|||
] |
|||
print gnomeSort [3 1 2 8 5 7 9 4 6]</lang> |
|||
{{out}} |
|||
<pre>1 2 3 4 5 6 7 8 9</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
contributed by Laszlo on the ahk [http://www.autohotkey.com/forum/post-276379.html#276379 forum] |
contributed by Laszlo on the ahk [http://www.autohotkey.com/forum/post-276379.html#276379 forum] |