Hand a child a shuffled deck of cards and say "put these in order". Watch closely and you will see them invent a sorting algorithm on the spot — sliding each new card into its right place, or swapping neighbours that look wrong. Computers face the same job constantly: alphabetising contacts, ranking scores, ordering search results. There are many recipes for it, but three are the classics of GCSE: bubble sort, insertion sort and merge sort.
Bubble sort — swap neighbours
Bubble sort walks along the list comparing each pair of neighbours, swapping them if they are in the wrong order. After one full pass the largest value has "bubbled" to the end. It repeats passes until a whole pass makes no swaps. Simple to grasp, but slow — it can make roughly n² comparisons.
Insertion sort — build a sorted section
Insertion sort is how most people sort a hand of playing cards. It takes each item in turn and inserts it into its correct place among the items already sorted to its left, shuffling bigger cards along to make room. It is often quicker than bubble sort on nearly-sorted data.
Merge sort — divide and conquer
Merge sort uses decomposition: it splits the list in half, then halves again and again until every piece is a single item (which is already "sorted"). Then it merges pairs of pieces back together in order. It is much faster on big lists — about n×log₂n work — but it needs extra memory to hold the pieces.
| Sort | Idea | Speed on big lists | Extra memory |
|---|---|---|---|
| Bubble | Swap neighbours | Slow (n²) | Very little |
| Insertion | Insert into sorted part | Slow (n²) | Very little |
| Merge | Split then merge | Fast (n log n) | More |
Memory hook: Bubble = Bump neighbours; Insertion = slot cards In; Merge = split, then Mend back together.