Write a function ‘bubble_sort(arr)’ which will sort an array of integers using the “bubble sort” methodology. (http://en.wikipedia.org/wiki/Bubble_sort)
First and foremost, understand the difference between insertion sort and bubble sort.
Insertion sort: Faster because it compares a value against the entire array and places it in the right location in one go. (The .sort method does this).
Bubble sort: Slower because it compares only against the next index, thus resulting in more comparison steps before ending up in the right location.