Skip to content

Instantly share code, notes, and snippets.

@stochastic-thread
Created April 27, 2015 05:57
Show Gist options
  • Save stochastic-thread/226dc7f0ae627847c91c to your computer and use it in GitHub Desktop.
Save stochastic-thread/226dc7f0ae627847c91c to your computer and use it in GitHub Desktop.
Quicksort in Elixir
defmodule Sorting do
def qsort(list) do
case list do
[] -> []
_ ->
[h|t] = list
qsort(for n <- t, n < h, do: n)
++ [h] ++
qsort(for n <- t, n >= h, do: n)
end
end
end
IO.inspect Sorting.qsort([10,123,443,2,3,2,1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment