Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Created April 23, 2019 08:15
Show Gist options
  • Select an option

  • Save 4skinSkywalker/2d45c8915d210172b4c52bc3dfa5ad25 to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/2d45c8915d210172b4c52bc3dfa5ad25 to your computer and use it in GitHub Desktop.
function insertionSort(array) {
for (var i = 1; i < array.length; i++) {
for (var j = i; j > 0 && !(array[j] > array[j - 1]); j--) {
if (array[j] < array[j - 1]) {
[array[j - 1], array[j]] = [array[j], array[j - 1]]
}
}
}
return array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment