mirror of
https://github.com/0xAX/go-algorithms
synced 2024-11-13 13:10:30 +00:00
16 lines
258 B
Go
16 lines
258 B
Go
package main
|
|
|
|
/*
|
|
* Bubble sort - http://en.wikipedia.org/wiki/Bubble_sort
|
|
*/
|
|
|
|
func BubbleSort(arr []int) {
|
|
for i := 0; i < len(arr); i++ {
|
|
for j := 0; j < len(arr)-1-i; j++ {
|
|
if arr[j] > arr[j+1] {
|
|
arr[j],arr[j+1] = arr[j+1],arr[j]
|
|
}
|
|
}
|
|
}
|
|
}
|