Created
April 24, 2016 20:25
-
-
Save galenweber/f4c93ff97270e7323d86f3ceef3e41b1 to your computer and use it in GitHub Desktop.
This file contains 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
var insertionSortwSplice = function(array) { | |
for (var i = 1; i < array.length; i++) { | |
for (var x = 0; x < i; x++ ) { | |
if (array[i] < array[x]) { | |
// Calling splice twice has got to be inefficient | |
array.splice(x,0,array[i]); | |
array.splice(i+1,1); | |
} | |
} | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment