Last active
October 1, 2016 17:29
-
-
Save billyma128/0ba626759e1e8b85a445 to your computer and use it in GitHub Desktop.
使用ES6实现快排
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 quicksort(head,...tail) { | |
if (!head) return []; | |
return quicksort(...tail.filter( _ => _ <= head)) | |
.concat([head]) | |
.concat(quicksort(...tail.filter( _ => _ > head ))) | |
} | |
// 传入参数quicksort(1,4,2,3)或quicksort(...[1,4,2,3]) |
liubiantao
commented
Oct 1, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment