Sorting algorithms/Shell sort: Difference between revisions

Content added Content deleted
(Updated to work with version 1.4 of Nim.)
(Added 11l)
Line 20: Line 20:
Other good sequences are found at the [https://oeis.org/search?q=shell+sort On-Line Encyclopedia of Integer Sequences].
Other good sequences are found at the [https://oeis.org/search?q=shell+sort On-Line Encyclopedia of Integer Sequences].
<br><br>
<br><br>

=={{header|11l}}==
{{trans|Python}}

<lang 11l>F shell_sort(&seq)
V inc = seq.len I/ 2
L inc != 0
L(el) seq[inc..]
V i = L.index + inc
L i >= inc & seq[i - inc] > el
seq[i] = seq[i - inc]
i -= inc
seq[i] = el
inc = I inc == 2 {1} E inc * 5 I/ 11

V data = [22, 7, 2, -5, 8, 4]
shell_sort(&data)
print(data)</lang>

{{out}}
<pre>
[-5, 2, 4, 7, 8, 22]
</pre>


=={{header|360 Assembly}}==
=={{header|360 Assembly}}==
Line 104: Line 127:
-31 0 1 2 2 4 45 58 65 69 74 82 82 83 88 89 99 104 112 782
-31 0 1 2 2 4 45 58 65 69 74 82 82 83 88 89 99 104 112 782
</pre>
</pre>

=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}