Sorting algorithms/Strand sort: Difference between revisions

m
Line 670:
{{trans|Python}}
<lang julia>function mergelist(a, b)
out = Vector{Int}()
while !isempty(a) && !isempty(b)
if a[1] < b[1]
push!(out, popfirst!(a))
else
push!(out, popfirst!(b))
end
end
Line 684:
function strand(a)
i, s = 1, [popfirst!(a)]
while i < length(a) + 1
if a[i] > s[end]
append!(s, splice!(a, i))
else
i += 1
end
end
s
s
end
 
strandsort(a) = (out = strand(a); while !isempty(a) out = mergelist(out, strand(a)) end; out)
Line 701:
[1, 1, 2, 3, 3, 5, 6, 7]
</pre>
 
 
=={{header|Kotlin}}==
4,102

edits