Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent pairs and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list. -- Wikipedia (https://en.wikipedia.org/wiki/Bubble_sort)
Create a function, bubleSort
, that takes a list of integers and sorts them in non-decreasing order using a bubble sort algorithm.
For example:
bubbleSort([]int{9,5,23,11,2}) // should return []int{2, 5, 9, 11, 23}
[]int{5, 2, 4, 1} // []int{1, 2, 4, 5}
[]int{199,-15, 0, 59} // []int{-15, 0, 59, 199}
[]int{0, 0, 0, -1} // []int{-1, 0, 0, 0}