Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
m
Undo revision 133288 by 94.139.167.104; incomprehensible reason given for removal
(100 times a letter to the three methods while, do while you implement in php language.) |
m (Undo revision 133288 by 94.139.167.104; incomprehensible reason given for removal) |
||
Line 2,046:
}
}
}</lang>
=={{header|PHP}}==
<lang php>function bubbleSort( array &$array )
{
do
{
$swapped = false;
for( $i = 0, $c = count( $array ) - 1; $i < $c; $i++ )
{
if( $array[$i] > $array[$i + 1] )
{
list( $array[$i + 1], $array[$i] ) =
array( $array[$i], $array[$i + 1] );
$swapped = true;
}
}
}
while( $swapped );
}</lang>
|