Skip to content

Instantly share code, notes, and snippets.

@educartoons
Last active June 15, 2020 04:29
Show Gist options
  • Select an option

  • Save educartoons/064fb8e9055a660aa9c2bfb00b989070 to your computer and use it in GitHub Desktop.

Select an option

Save educartoons/064fb8e9055a660aa9c2bfb00b989070 to your computer and use it in GitHub Desktop.
Sorting by Insertion implemented in Go
func insertionSort(A []int) []int {
for j := 0; j < len(A); j++ {
var key = A[j]
var i = j - 1
for i >= 0 && A[i] > key {
A[i+1] = A[i]
i = i - 1
}
A[i+1] = key
}
return A
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment