Skip to content

Instantly share code, notes, and snippets.

@educartoons
Created June 18, 2020 01:51
Show Gist options
  • Save educartoons/edee80cd85f8c130ef353863f7a91959 to your computer and use it in GitHub Desktop.
Save educartoons/edee80cd85f8c130ef353863f7a91959 to your computer and use it in GitHub Desktop.
Implementation of Selection Sort in Go
func selectionSort(A []int) []int {
for i := 0; i < len(A)-1; i++ {
var min = i
for j := i + 1; j < len(A); j++ {
if A[j] < A[min] {
min = j
}
}
A[min], A[i] = A[i], A[min]
}
return A
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment