Created
May 9, 2012 19:06
-
-
Save mjn/2648067 to your computer and use it in GitHub Desktop.
Erlang implementation of insertion sort
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
-module(inssort). | |
-export([sort/1]). | |
sort([]) -> | |
[]; | |
sort([ First ]) -> | |
[ First ]; | |
sort([ First, Second | T ]) -> | |
if | |
First > Second -> | |
[ Second ] ++ sort([ First] ++ T); | |
true -> | |
[ First, Second ] ++ sort(T) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested? You are not right. Right one:
http://rosettacode.org/wiki/Sorting_algorithms/Insertion_sort#Erlang