Last active
August 29, 2015 13:58
-
-
Save esimov/10019083 to your computer and use it in GitHub Desktop.
Bubblesort in Golang
This file contains hidden or 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
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