Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
(Updated D code) |
|||
Line 638: | Line 638: | ||
=={{header|D}}== |
=={{header|D}}== |
||
<lang d>import std.stdio, std.algorithm; |
<lang d>import std.stdio, std.algorithm; |
||
void bubbleSort( |
void bubbleSort(T)(T[] data) pure nothrow { |
||
int itemCount = data.length; |
int itemCount = data.length; |
||
bool hasChanged = false; |
bool hasChanged = false; |
||
do { |
do { |
||
hasChanged = false; |
hasChanged = false; |
||
Line 653: | Line 653: | ||
} while (hasChanged); |
} while (hasChanged); |
||
} |
} |
||
void main() { |
void main() { |
||
auto array = [28, 44, 46, 24, 19, 2, 17, 11, 25, 4]; |
auto array = [28, 44, 46, 24, 19, 2, 17, 11, 25, 4]; |