Created
June 23, 2015 15:25
-
-
Save goesang/3614363f391eb5f41bfd 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(items) { | |
| for (i=0; i < items.length; i++) { | |
| var value = items[i]; | |
| var j; | |
| for (j=i-1; j > -1 && items[j] > value; j--) | |
| items[j+1] = items[j]; | |
| items[j+1] = value; | |
| } | |
| return items; | |
| } | |
| alert(insertionSort([0,50,6,3,5,2,1,2])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment