-
-
Save eengineergz/ffead1de0836c4bcc6445780a604f617 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
let insertionSort = (inputArr) => { | |
let length = inputArr.length; | |
for (let i = 1; i < length; i++) { | |
let key = inputArr[i]; | |
let j = i - 1; | |
while (j >= 0 && inputArr[j] > key) { | |
inputArr[j + 1] = inputArr[j]; | |
j = j - 1; | |
} | |
inputArr[j + 1] = key; | |
} | |
return inputArr; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment