Sorting algorithms/Comb sort: Difference between revisions

Content added Content deleted
(Added Kotlin)
(Added Julia language)
Line 1,180: Line 1,180:
| .[0] = $gap )
| .[0] = $gap )
| .[2] ;</lang>
| .[2] ;</lang>

=={{header|Julia}}==
<lang julia># v0.6

function combsort!(x::Array)::Array
gap, swaps = length(x), true
while gap > 1 || swaps
gap = floor(Int, gap / 1.25)
i, swaps = 0, false
while i + gap < length(x)
if x[i+1] > x[i+1+gap]
x[i+1], x[i+1+gap] = x[i+1+gap], x[i+1]
swaps = true
end
i += 1
end
end
return x
end

x = randn(100)
@show x combsort!(x)
@assert issorted(x)</lang>

{{out}}
<pre>x = [1.41167, 1.19626, 0.821703, 0.336024, -0.708447, 0.694578, 1.49075, -1.07124, -1.59686, -0.720135]
combsort!(x) = [-1.59686, -1.07124, -0.720135, -0.708447, 0.336024, 0.694578, 0.821703, 1.19626, 1.41167, 1.49075]</pre>


=={{header|Kotlin}}==
=={{header|Kotlin}}==