Created
February 17, 2018 00:25
-
-
Save kevinfiol/4a13f8df719db5eee2e083805da46bc4 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
function bigBoySort(arr) { | |
if (arr.length < 2) { | |
return arr; | |
} | |
let p = arr[0]; | |
let lo = []; | |
let hi = []; | |
for (let i = 1; i < arr.length; i++) { | |
if (arr[i] > p) { | |
hi.push(arr[i]); | |
} else { | |
lo.push(arr[i]); | |
} | |
} | |
return [...bigBoySort(lo), p, ...bigBoySort(hi)]; | |
}; |
function babySort(arr) {
return arr.sort();
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const babySort = (arr) => arr.sort();