bubble sort bonus: where the laughs are as slow as the algorithm
in this bonus episode, we'll be sorting an array of items using the most inefficient, yet somehow endearing, algorithm of them all: bubble sort.
why bubble sort? why not?
because, quite frankly, why not? it's not like we have better things to do. like, have you seen our to-do list? 'sort this list of items'? 'reorganize the pantry'? 'call our therapist about our love life'? nah, bubble sort is a breeze.
here's how it works:
bubble sort 101
- start at the beginning of the list
- compare the first two items. if they're in order, move on to the next two items.
- if they're not, swap them.
- repeat steps 2-3 until the end of the list.
it's like a game of 'compare and despair'!
algorithmic awesomesort sorted out better algorithms