Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 17, 2021 00:18
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 parzibyte/d7db84685b31597ff9833fd942bab7bd to your computer and use it in GitHub Desktop.
Save parzibyte/d7db84685b31597ff9833fd942bab7bd to your computer and use it in GitHub Desktop.
<?php
function burbuja(&$arreglo)
{
$longitud = count($arreglo);
for ($i = 0; $i < $longitud; $i++) {
for ($j = 0; $j < $longitud - 1; $j++) {
if ($arreglo[$j] > $arreglo[$j + 1]) {
$temporal = $arreglo[$j];
$arreglo[$j] = $arreglo[$j + 1];
$arreglo[$j + 1] = $temporal;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment