Last active
November 26, 2019 23:28
-
-
Save mitrakmt/9e1b3440db54daa78bd9a4db0ceea3c1 to your computer and use it in GitHub Desktop.
Revisions
-
mitrakmt revised this gist
Nov 26, 2019 . 1 changed file with 12 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,14 @@ const insertionSort = (array) => { const length = array.length; for (let i = 1; i < length; i++) { let key = array[i]; let j = i - 1; while (j >= 0 && array[j] > key) { array[j + 1] = array[j]; j = j - 1; } array[j+1] = key; } return array; }; -
mitrakmt revised this gist
Jul 18, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ function insertionSort(array) { var length = array.length; for(var i = 1, j; i < length; i++) { var temp = array[i]; for(var j = i - 1; j >= 0 && array[j] > temp; j--) { array[j+1] = array[j]; -
mitrakmt revised this gist
Oct 1, 2016 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ function insertionSort(array) { var length = array.length; for(var i = 1; i < length; i++) { var temp = array[i]; for(var j = i - 1; j >= 0 && array[j] > temp; j--) { array[j+1] = array[j]; } array[j+1] = temp; } return array; } -
mitrakmt revised this gist
Sep 29, 2016 . 1 changed file with 9 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,12 @@ function insertionSort(array) { var length = array.length; for(var i = 1; i < length; ++i) { var temp = array[i]; var j = i - 1; for(; j >= 0 && array[j] > temp; --j) { array[j+1] = array[j]; } array[j+1] = temp; } return array; }; -
mitrakmt created this gist
Sep 29, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function sort(array, compare) { for (var i = 1; i < array.length; i++) { var item = array[i]; var indexHole = i; while (indexHole > 0 && compare(array[indexHole - 1], item) > 0) { array[indexHole] = array[--indexHole]; } array[indexHole] = item; if (sortExternal.shiftObserver) { sortExternal.shiftObserver(i, indexHole); } } return array; }