MCPcopy Create free account
hub / github.com/0xAX/go-algorithms / InsertionSort

Function InsertionSort

sorting/insertion_sort.go:7–16  ·  view source on GitHub ↗

* * Insertion sort - https://en.wikipedia.org/wiki/Insertion_sort */

(arr []int)

Source from the content-addressed store, hash-verified

5 */
6
7func InsertionSort(arr []int) {
8 var i, j int
9 for i = 1; i < len(arr); i++ {
10 for j = 0; j < i; j++ {
11 if arr[j] > arr[i] {
12 arr[i], arr[j] = arr[j], arr[i]
13 }
14 }
15 }
16}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected