Skip to content

Instantly share code, notes, and snippets.

@Neo42
Last active March 25, 2022 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Neo42/4cc3e9dc59dae9d7f58c00b77eee5370 to your computer and use it in GitHub Desktop.
Save Neo42/4cc3e9dc59dae9d7f58c00b77eee5370 to your computer and use it in GitHub Desktop.
Functional quick sort in 8 lines (non in-place)
const quickSort = ([pivot, ...rest]) =>
pivot
? [
...quickSort(rest.filter(x => x < pivot)),
pivot,
...quickSort(rest.filter(y => y >= pivot))
]
: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment