Sorting algorithms/Shell sort: Difference between revisions
Content added Content deleted
(Added in-place solution in Swift 2.1, based on Python in-place example.) |
mNo edit summary |
||
Line 2,026: | Line 2,026: | ||
─────────────────────────────────────────────────────────────────────────────── |
─────────────────────────────────────────────────────────────────────────────── |
||
</pre> |
</pre> |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
siz = 100 |
|||
a = list(siz) |
|||
for i = 1 to siz |
|||
a[i] = floor(random(100)) |
|||
see a[i] + nl |
|||
next |
|||
incr = floor(siz / 2) |
|||
while incr > 0 |
|||
for i = 1 to siz |
|||
j = i |
|||
temp = a[i] |
|||
while (j >= incr and fabs(j-incr) > 0 and a[fabs(j-incr)] > temp) |
|||
a[j] = a[j-incr] |
|||
j = j - incr |
|||
end |
|||
a[j] = temp |
|||
next |
|||
incr = floor(incr / 2.2) |
|||
end |
|||
for i = 1 to siz |
|||
see a[i] + nl |
|||
next |
|||
</lang> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |