Skip to content

Instantly share code, notes, and snippets.

@ympons
Created January 30, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ympons/9ad44750c7253dfabd7a29b0b50a3b08 to your computer and use it in GitHub Desktop.
Save ympons/9ad44750c7253dfabd7a29b0b50a3b08 to your computer and use it in GitHub Desktop.
Simple QuickSort implementation in Elixir
defmodule QuickSort do
def sort([]), do: []
def sort([head|tail]) do
{l, r} = Enum.partition(tail, &(&1 > head))
sort(l) ++ [head] ++ sort(r)
end
end
a = QuickSort.sort([3, 1, 2, 5])
IO.inspect a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment