2
0
mirror of https://github.com/0xAX/go-algorithms synced 2024-11-13 13:10:30 +00:00
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]
}
}
}
}