MCPcopy Create free account
hub / github.com/arnauddri/algorithms / sort

Function sort

algorithms/sorting/selection-sort/selection.go:3–16  ·  view source on GitHub ↗
(arr []int)

Source from the content-addressed store, hash-verified

1package selection
2
3func sort(arr []int) []int {
4 for i := 0; i < len(arr); i++ {
5 min := i
6 for j := i + 1; j < len(arr); j++ {
7 if arr[j] < arr[min] {
8 min = j
9 }
10 }
11 if min != i {
12 arr[i], arr[min] = arr[min], arr[i]
13 }
14 }
15 return arr
16}

Callers 2

TestSelectionSortFunction · 0.70
benchmarkSelectionSortFunction · 0.70

Calls

no outgoing calls

Tested by 2

TestSelectionSortFunction · 0.56
benchmarkSelectionSortFunction · 0.56