insertionSort

Run Settings
LanguageJavaScript
Language Version
Run Command
function insertionSort(nums){ for(let i=1; i<nums.length; i++){ for(let j=0; j<i; j++){ if(nums[i]<nums[j]){ let numsI=nums[i] shift(j,i); nums[j]=numsI } } } return nums function shift(start, end){ for(let i=end; i>start; i--){ nums[i]=nums[i-1]; } } } console.log(insertionSort([5,3,7,1,2]))
Editor Settings
Theme
Key bindings
Full width
Lines