Introduction to sorting
Sorting is a common operation, and there are dozens of algorithms we can use to sort a vector or array. Of course, sorting requires that elements in the underlying data structure are comparable.
Bubble sort is like the “Hello World” of sorting algorithms. It’s never used in practice (we’ll see why soon), but it is one of the easiest sorting algorithms to understand. Accordingly, we’ll start with bubble sort. Here’s a coding session where we implement bubble sort, and progressively improve on the implementation.
Resources
Copyright © 2023–2025 Clayton Cafiero
No generative AI was used in producing this material. This was written the old-fashioned way.