You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-algorithms/sorting/insertion_sort.go

17 lines
265 B
Go

package main
/*
* Insertion sort - https://en.wikipedia.org/wiki/Insertion_sort
*/
func InsertionSort(arr []int) {
var i, j int
for i = 1; i < len(arr); i++ {
for j = 0; j < i; j++ {
if arr[j] > arr[i] {
arr[i], arr[j] = arr[j], arr[i]
}
}
}
}