Skip to content

Instantly share code, notes, and snippets.

@educartoons
Created June 15, 2020 22:44
Show Gist options
  • Save educartoons/c8c345b804861a15c5c4f09d6f6614db to your computer and use it in GitHub Desktop.
Save educartoons/c8c345b804861a15c5c4f09d6f6614db to your computer and use it in GitHub Desktop.
Implementation of Bubble Sort in Go
func bubbleSort(A []int) []int {
for i := 1; i < len(A); i++ {
for j := len(A) - 1; j >= i; j-- {
if A[j-1] > A[j] {
A[j-1], A[j] = A[j], A[j-1]
}
}
}
return A
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment