Created
June 11, 2015 11:02
-
-
Save mtanzi/0877b0d640019ed895a9 to your computer and use it in GitHub Desktop.
Quick sort in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Math do | |
def sort([h | t]) do | |
sort(for x <- t, x < h, do: x) ++ [h] ++ sort(for x <- t, x >= h, do: x) | |
end | |
def sort([]), do: [] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment