MCPcopy 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

3import ()
4
5func 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

TestInsertionSortFunction · 0.70
benchmarkInsertionSortFunction · 0.70

Calls

no outgoing calls

Tested by 2

TestInsertionSortFunction · 0.56
benchmarkInsertionSortFunction · 0.56