Created
October 25, 2012 06:30
-
-
Save island205/3950852 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
| insertSort = (arr)-> | |
| for i in [1...arr.length] | |
| for j in [i-1..0] | |
| if arr[j] > arr[j+1] | |
| temp = arr[j] | |
| arr[j] = arr[j+1] | |
| arr[j+1] = temp | |
| arr | |
| #test | |
| console.log insertSort [1,2,3,3,4,6, 9, 2, 1] | |
| console.log insertSort [1] | |
| console.log insertSort [0] | |
| console.log insertSort [1,0] | |
| console.log insertSort [1,0,1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment