Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 18:31
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/030d253c492b09f1de849464a8d2a74e to your computer and use it in GitHub Desktop.
Save parzibyte/030d253c492b09f1de849464a8d2a74e to your computer and use it in GitHub Desktop.
Ordenar arreglo numérico con PHP - https://parzibyte.me/blog/2018/10/15/ordenar-arreglo-php/
<?php
/*
Ordenar un arreglo numérico en PHP
@author parzibyte.me/blog
Nota: si quieres cambiar el orden, simplemente invierte el arreglo después de ordenarlo:
https://parzibyte.me/blog/2018/10/15/invertir-arreglo-php/
*/
# El arreglo que tiene números desordenados
$numeros = [96, 28, 11, 55, 20, 2015, 500, 630, -10, -1, 200, 96];
echo "El arreglo desordenado:\n";
print_r($numeros);
#Lo ordenamos de modo numérico
sort($numeros, SORT_NUMERIC);
echo "El arreglo después de haber sido ordenado:\n";
print_r($numeros);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment