Skip to content

Instantly share code, notes, and snippets.

@ruancarvalho
Created April 7, 2019 00:46
Show Gist options
  • Save ruancarvalho/f4dbc43102e8a8243782da8cf7f0c569 to your computer and use it in GitHub Desktop.
Save ruancarvalho/f4dbc43102e8a8243782da8cf7f0c569 to your computer and use it in GitHub Desktop.
Algorithms JS
const insertionSort = function(A) {
for (let j = 1; j <= A.length; j++) {
let key = A[j];
let i = j-1;
while (i >= 0 && A[i] > key) {
A[i+1] = A[i];
i = i-1;
A[i+1] = key;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment