Created
October 25, 2012 09:04
-
-
Save island205/3951536 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
| quickSort = (arr)-> | |
| debugger | |
| return arr if arr.length < 2 | |
| left = [] | |
| right = [] | |
| for i in [1...arr.length] | |
| if arr[0] > arr[i] | |
| left.push arr[i] | |
| else | |
| right.push arr[i] | |
| debugger | |
| [].concat quickSort(left), arr[0], quickSort(right) | |
| #test | |
| console.log quickSort [1,2,3,3,4,6, 9, 2, 1] | |
| console.log quickSort [1] | |
| console.log quickSort [0] | |
| console.log quickSort [1,0] | |
| console.log quickSort [1,0,1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment