Skip to content

Instantly share code, notes, and snippets.

@oskimura
Created October 3, 2010 07:45
Show Gist options
  • Save oskimura/608372 to your computer and use it in GitHub Desktop.
Save oskimura/608372 to your computer and use it in GitHub Desktop.
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