Sorting algorithms/Shell sort: Difference between revisions

(Adding Dart implementation of the algorithm)
Line 2,711:
}
</lang>
 
=={{header|Picat}}==
Using the algorithm from the Wikipedia page, inline sort.
<lang Picat>go =>
A = [23, 76, 99, 58, 97, 57, 35, 89, 51, 38, 95, 92, 24, 46, 31, 24, 14, 12, 57, 78],
println(A),
shell_sort(A),
println(A),
nl.
 
% Inline sort
shell_sort(A) =>
Inc = round(A.length/2),
while (Inc > 0)
foreach(I in Inc+1..A.length)
Temp = A[I],
J := I,
while (J > Inc, A[J-Inc] > Temp)
A[J] := A[J-Inc],
J := J - Inc
end,
A[J] := Temp
end,
Inc := round(Inc/2.2)
end.</lang>
 
{{out}}
<pre>[23,76,99,58,97,57,35,89,51,38,95,92,24,46,31,24,14,12,57,78]
[12,14,23,24,24,31,35,38,46,51,57,57,58,76,78,89,92,95,97,99]</pre>
 
 
=={{header|PicoLisp}}==
495

edits