Skip to content

Instantly share code, notes, and snippets.

@esimov
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimov/10019083 to your computer and use it in GitHub Desktop.
Save esimov/10019083 to your computer and use it in GitHub Desktop.
Bubblesort in Golang
package main
import (
"fmt"
)
func BubbleSort(arr[] int)[]int {
for i:=1; i< len(arr); i++ {
for j:=0; j < len(arr)-i; j++ {
if (arr[j] > arr[j+1]) {
arr[j], arr[j+1] = arr[j+1], arr[j]
}
}
}
return arr
}
func main() {
var bubble []int = []int{21,123,32,4,5,677,8,33}
fmt.Println("----------------Bubblesort----------------")
fmt.Println(BubbleSort(bubble))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment