Skip to content

Instantly share code, notes, and snippets.

@samuel1112
Last active September 29, 2015 04:24
Show Gist options
  • Save samuel1112/b8f4bf9cece2f8fa85da to your computer and use it in GitHub Desktop.
Save samuel1112/b8f4bf9cece2f8fa85da to your computer and use it in GitHub Desktop.
function quicksort(arr){
if(arr.length){
var x = arr.shift(),
smallersort = quicksort(arr.filter(function (item){
return item<x;
})),
biggersort = quicksort(arr.filter(function (item){
return item>=x;
}));
return smallersort.concat([x],biggersort);
} else {
return [];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment