Created
August 23, 2016 02:38
-
-
Save dengjonathan/05d4d796f60deb8e1ac3a6f1b606667c to your computer and use it in GitHub Desktop.
This file contains 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
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