Created
December 6, 2013 04:27
-
-
Save agar3s/7818566 to your computer and use it in GitHub Desktop.
Una corta explicación de bubbleSort para ordenamiento de arreglos.
http://youtu.be/v5kLxVtYF9k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ordenar(numeros){ | |
for(var i=0; i<numeros.length; i++){ | |
numeros[i] = parseInt(numeros[i]); | |
} | |
for(i=0; i<numeros.length; i++){ | |
for(var j=0; j<numeros.length-1; j++){ | |
if(numeros[j] > numeros[j+1]){ | |
var tmp = numeros[j+1]; | |
numeros[j+1] = numeros[j]; | |
numeros[j] = tmp; | |
} | |
} | |
} | |
return numeros; | |
} | |
var numeros = ordenar(process.argv.slice(2)); | |
console.log(numeros); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment