Skip to content

Instantly share code, notes, and snippets.

@parroty
Created October 27, 2013 13:23
Show Gist options
  • Save parroty/7182043 to your computer and use it in GitHub Desktop.
Save parroty/7182043 to your computer and use it in GitHub Desktop.
Elixir QuickSort
defmodule QuickSort do
def sort([]), do: []
def sort([head|tail]) do
{lesser, greater} = Enum.partition(tail, &(&1 < head))
sort(lesser) ++ [head] ++ sort(greater)
end
end
IO.inspect QuickSort.sort([1,6,3,4,2,5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment