Untitled
unknown
javascript
a year ago
350 B
3
Indexable
// Insertion Sort function insertionSort(arr){ for(let i=1; i<arr.length;i++){ elm = arr[i] let j; for(j=i-1; j>=0;j--){ if(arr[j]>elm){ arr[j+1]=arr[j] }else{ break; } }arr[j+1]=elm } } arr=[1,3,-1,5,2,6] insertionSort(arr) console.log(arr)
Editor is loading...
Leave a Comment