Skip to content

Instantly share code, notes, and snippets.

@Dornhoth
Last active July 2, 2020 19:49
Show Gist options
  • Select an option

  • Save Dornhoth/3c31553594ad6f2e28cfef2ee04aa3f5 to your computer and use it in GitHub Desktop.

Select an option

Save Dornhoth/3c31553594ad6f2e28cfef2ee04aa3f5 to your computer and use it in GitHub Desktop.
function insertionSort(array) {
let i = 1;
let x;
while (i < array.length) {
x = array[i]
let j = i - 1;
while (j >= 0 && array[j] > x) {
array[j + 1] = array[j];
j = j - 1;
}
array[j + 1] = x;
i = i + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment