Skip to content

Instantly share code, notes, and snippets.

@bobfirestone
Created July 13, 2017 17:11
Show Gist options
  • Save bobfirestone/8abc5ca81dc0760c6dd8b9fe89534fac to your computer and use it in GitHub Desktop.
Save bobfirestone/8abc5ca81dc0760c6dd8b9fe89534fac to your computer and use it in GitHub Desktop.
Elixir implementation of Trump Sort
defmodule TrumpSort do
def sort([h|tail]) do
[ h | sort(tail,h) ]
end
def sort([], _wall) do
[]
end
def sort([h|tail], wall) when h > wall do
[ h| sort(tail,h) ]
end
def sort([_h|tail], wall) do
sort(tail, wall)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment