(arr []T)
| 9 | import "github.com/TheAlgorithms/Go/constraints" |
| 10 | |
| 11 | func Insertion[T constraints.Ordered](arr []T) []T { |
| 12 | for currentIndex := 1; currentIndex < len(arr); currentIndex++ { |
| 13 | temporary := arr[currentIndex] |
| 14 | iterator := currentIndex |
| 15 | for ; iterator > 0 && arr[iterator-1] > temporary; iterator-- { |
| 16 | arr[iterator] = arr[iterator-1] |
| 17 | } |
| 18 | arr[iterator] = temporary |
| 19 | } |
| 20 | return arr |
| 21 | } |
no outgoing calls
no test coverage detected