Created
October 3, 2010 07:45
-
-
Save oskimura/608372 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function insertSort(a) | |
for j=1, table.maxn(a) do | |
key = a[j] | |
i = j-1 | |
while i>=1 and a[i]>key do | |
a[i+1] = a[i] | |
i = i-1 | |
end | |
a[i+1] = key | |
end | |
end | |
a={2,1} | |
insertSort(a) | |
print(table.concat(a,',',1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment