Created
April 23, 2019 08:15
-
-
Save 4skinSkywalker/2d45c8915d210172b4c52bc3dfa5ad25 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
| function insertionSort(array) { | |
| for (var i = 1; i < array.length; i++) { | |
| for (var j = i; j > 0 && !(array[j] > array[j - 1]); j--) { | |
| if (array[j] < array[j - 1]) { | |
| [array[j - 1], array[j]] = [array[j], array[j - 1]] | |
| } | |
| } | |
| } | |
| return array | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment