Anonymous user
Sorting algorithms/Heapsort: Difference between revisions
Updated second D entry, and swapped the two entries
Walterpachl (talk | contribs) m (moved PL/I) |
(Updated second D entry, and swapped the two entries) |
||
Line 608:
=={{header|D}}==
<lang d>import std.stdio, std.container;▼
void heapSort(T)(T[] data) /*pure nothrow*/ {
for (auto h = data.heapify; !h.empty; h.removeFront) {}
}▼
void main() {▼
items.heapSort;
}</lang>▼
A lower level implementation:
<lang d>import std.stdio, std.algorithm;
Line 633 ⟶ 646:
siftDown(seq, 0, end - 1);
}
▲}
▲void main() {
▲ auto arr = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0];
▲ writeln(arr);
▲}</lang>
▲<lang d>import std.stdio, std.container;
}
|