-- quicksort.hs — naive functional quicksort.
--
-- Partition by pivot, recurse on each half, concatenate.
-- Uses right sections `(< x)` and `(>= x)` with filter.

qsort [] = []
qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
  where
    smaller = filter (< x) xs
    larger  = filter (>= x) xs

result = qsort [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
