Created
July 15, 2015 09:04
-
-
Save Aleksey-Danchin/6cdb2ab3af88925aff06 to your computer and use it in GitHub Desktop.
Sort by Insert Method.
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 insertSort (array) { | |
| for (var i = 1; i < array.length; i++) { | |
| var key = array[i], j = i - 1; | |
| while (j > -1 && array[j] > key) | |
| array[j + 1] = array[j--]; | |
| array[j + 1] = key; | |
| } | |
| return array; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment