Created
June 15, 2020 22:44
-
-
Save educartoons/c8c345b804861a15c5c4f09d6f6614db to your computer and use it in GitHub Desktop.
Implementation of Bubble Sort in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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