Skip to content

Instantly share code, notes, and snippets.

@caioerick
Created June 2, 2014 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caioerick/f23a057c011b92281b51 to your computer and use it in GitHub Desktop.
Save caioerick/f23a057c011b92281b51 to your computer and use it in GitHub Desktop.
Booble Sort em PHP
<?php
$vet[5] = Array(1, 3, 5, 2, 4);
for($i=0;$i<5;$i++) {
for($j=0;$j<4;$j++) {
if($vet[$j] > $vet[$j+1]) {
$aux = $vet[$j];
$vet[$j] = $vet[$j+1];
$vet[$j+1] = $aux;
}
}
}
for($i=0;$i<5;$i++) {
echo $vet[$i];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment