Skip to content

Instantly share code, notes, and snippets.

@agar3s
Created December 6, 2013 04:27
Show Gist options
  • Save agar3s/7818566 to your computer and use it in GitHub Desktop.
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
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