Sorting algorithms/Heapsort: Difference between revisions

Content added Content deleted
Line 1,995: Line 1,995:
=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>function pd!(a, first, last)
<lang julia>function pd!(a, first, last)
r = first
while (c = 2 * first - 1) < last
while (c = 2 * r - 1) < last
if c < last && a[c] < a[c + 1]
if c < last && a[c] < a[c + 1]
c += 1
c += 1
end
end
if a[r] < a[c]
if a[first] < a[c]
a[c], a[r] = a[r], a[c]
a[c], a[first] = a[first], a[c]
r = c
first = c
else
else
break
break