Four classic ways to put a list in order, side by side.
The idea
Sorting a hand of playing cards shows the big ideas:
Bubble sort: repeatedly compare neighbours and swap if out of order. The biggest card “bubbles” to the end each pass. Easy, but slow.
Insertion sort: pick up cards one at a time and slide each into the right place among the cards you already hold.
Merge sort: split the pile in half, sort each half (the same way), then merge two sorted piles by always taking the smaller top card. Divide and conquer.
Quick sort: pick a pivot card; put smaller cards on its left and bigger ones on its right. The pivot is now in its final place; repeat on both sides.
Watch it work
Try it
Run each algorithm on the same numbers and compare the comparisons counts shown under the boxes.
Give bubble and insertion an already-sorted list. Which finishes with fewer swaps/shifts?
Give them a reverse-sorted list (9, 8, 7, 6, 5, 4). Which one suffers most?
Quick sort: use a sorted list. The last-item pivot is a bad choice there. What happens to the number of steps?
Add duplicate values like 3, 3, 3, 1 and watch how each algorithm treats equal items.
Common mistakes
Off-by-one in bubble sort's inner loop: compare a[j] with a[j+1], so j must stop one before the unsorted end.
Merge sort: forgetting the leftovers after one half runs out.
Quick sort with a bad pivot (always smallest/largest) degrades to O(n²). Real implementations pick a random or median pivot.
Writing your own sort in real Go code: use slices.Sort or sort.Slice; they are faster and tested.
How fast is it?
Bubble & insertion: O(n²) time (insertion is O(n) on nearly sorted data), O(1) space. Merge sort: O(n log n) always, O(n) extra space. Quick sort: O(n log n) on average, O(n²) worst case, O(log n) stack space.