Skip to content

Instantly share code, notes, and snippets.

@chomado
Created May 17, 2013 15:46
Show Gist options
  • Save chomado/5599957 to your computer and use it in GitHub Desktop.
Save chomado/5599957 to your computer and use it in GitHub Desktop.
mysort :: [Int] -> [Int]
mysort list = case list of
[] -> []
first : rest -> insert (mysort rest) first
where insert lst n = case lst of
[] -> [n]
first : rest
| first < n -> first : insert rest n
| otherwise -> n : lst
test1 = mysort [5, 3, 8, 1, 7, 4] == [1, 3, 4, 5, 7, 8]
test2 = mysort [8] == [8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment