Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sort
function quickSort(list) {
if (list.length < 2) {
return list
}
const candidate = list[list.length - 1]
const less = list.filter(i => i < candidate)
const greater = list.filter(i => i > candidate)
return [
...quickSort(less),
candidate,
...quickSort(greater)
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment