vusjtq
Last Updated: February 25, 2016
·
1.787K
· edgurgel

Quicksort in Elixir

defmodule Quick do
  def sort([]), do: []
  def sort([pivot | rest]) do
    { left, right } = Enum.partition(rest, &(&1 < pivot))
    sort(left) ++ [pivot | sort(right)]
  end
end
iex> Quick.sort [5, 4, 3, 2, 1]
[1, 2, 3, 4, 5]

http://elixir-lang.org/