Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created August 23, 2016 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dengjonathan/05d4d796f60deb8e1ac3a6f1b606667c to your computer and use it in GitHub Desktop.
Save dengjonathan/05d4d796f60deb8e1ac3a6f1b606667c to your computer and use it in GitHub Desktop.
var quickSort = function (arr) {
if (arr.length === 0) {
return [];
}
var left = [];
var right = [];
var pivot = arr[arr.length - 1]; // use right most value as pivot
_.each(arr.slice(0, arr.length - 1), function (each) {
if (each <= pivot) {
left.push(each);
} else {
right.push(pivot);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment