Bubble sort

One way to sort a list is to repeatedly walk along it comparing each pair of neighbours, and swapping them whenever the left one is bigger. After one full walk the largest value has "bubbled" to the end. Walk again, and the second largest settles next to it. After enough walks nothing needs swapping, and the list is sorted.

Write bubble_sort(nums) that sorts the list in place using this method and returns it. Do not use sort or sorted.

bubble_sort([5, 1, 4, 2])  ->  [1, 2, 4, 5]
def bubble_sort(nums):
    ...