Can you explain the mechanics of the Bubble sort algorithm?
Implement the algorithm as bubble_sort(values). It must rearrange the input array into ascending order and return the sorted array. Compare adjacent elements, swap them when they are out of order, and stop early if a complete pass makes no swaps.
values is an array of integers. Return the same array after sorting it in ascending order.
def bubble_sort(values):