Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/arnauddri/algorithms
/ sort
Function
sort
algorithms/sorting/insertion-sort/insertion.go:5–15 ·
view source on GitHub ↗
(arr []int)
Source
from the content-addressed store, hash-verified
3
import
()
4
5
func
sort(arr []int) {
6
for
i := 1; i < len(arr); i++ {
7
value := arr[i]
8
j := i - 1
9
for
j >= 0 && arr[j] > value {
10
arr[j+1] = arr[j]
11
j = j - 1
12
}
13
arr[j+1] = value
14
}
15
}
Callers
2
TestInsertionSort
Function · 0.70
benchmarkInsertionSort
Function · 0.70
Calls
no outgoing calls
Tested by
2
TestInsertionSort
Function · 0.56
benchmarkInsertionSort
Function · 0.56