Wait, if the standard sorted() function exists, why should we learn to write a sorting algorithm from scratch?

In all seriousness, in this chapter we'll be building some of the most famous sorting algorithms from scratch because:
Bubble sort is a very basic sorting algorithm named for the way elements "bubble up" to the top of the list.
Click to play video
Bubble sort repeatedly steps through a slice and compares adjacent elements, swapping them if they are out of order. It continues to loop over the slice until the whole list is completely sorted. Here's the pseudocode:
swapping to Trueend to the length of the input listswapping is True:
swapping to Falsei from the 2nd element to end:
(i-1)th element of the input list is greater than the ith element:
(i-1)th element and the ith elementswapping to Trueend by oneWhile our avocado toast influencers were happy with our search functionality, now they want to be able to sort all their followers by follower count. Bubble sort is a straightforward sorting algorithm that we can implement quickly, so let's do that!
Complete the bubble_sort function according to the described algorithm above.