Skip to content

Instantly share code, notes, and snippets.

@qodirovshohijahon
Created March 13, 2020 14:47
Show Gist options
  • Save qodirovshohijahon/f2010b1f80eb99f38ed6fcfd38e10fc6 to your computer and use it in GitHub Desktop.
Save qodirovshohijahon/f2010b1f80eb99f38ed6fcfd38e10fc6 to your computer and use it in GitHub Desktop.
Insert sort
function insert(arr) {
for(let i = 1; i < arr.length; i++) {
let key = arr[i];
let j = i - 1;
while(j >= 0 && arr[j] > key) {
arr[j+1] = arr[j];
j--;
}
arr[j+1] = key;
}
return arr;
}
und
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment