Created
May 7, 2019 03:04
-
-
Save JimRottinger/1e5828bb29c8993a385ce14616d1a8f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const insertionSort = (nums) => { | |
for (let i = 1; i < nums.length; i++) { | |
let j = i - 1 | |
let tmp = nums[i] | |
while (j >= 0 && nums[j] > tmp) { | |
nums[j + 1] = nums[j] | |
j-- | |
} | |
nums[j+1] = tmp | |
} | |
return nums | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment