Skip to content

Instantly share code, notes, and snippets.

@fetfrum
Created December 28, 2019 01:53
Show Gist options
  • Select an option

  • Save fetfrum/2f75ac575e1d868736e268e041051dc7 to your computer and use it in GitHub Desktop.

Select an option

Save fetfrum/2f75ac575e1d868736e268e041051dc7 to your computer and use it in GitHub Desktop.
Qsort Haskell
-- Quicksort algorithm by Tony Hoare
-- https://en.wikipedia.org/wiki/Quicksort
qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort (x:xs) =
let up = qsort [a | a <- xs, a > x]
down = qsort [a | a <- xs, a <= x]
in down ++ [x] ++ up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment