Sorting: merge sort and comparing algorithms

Merge sort is a 'divide and conquer' algorithm. It is much faster than bubble sort on big lists, which is why real programs use ideas like it.

Practise this lesson free (6 questions)

More tools

Divide

Keep splitting the list in half until every part has just one item. A list of one item is already sorted.
6, 2, 8, 4, 7, 1, 5, 3 splits into 8 single items.

Conquer: merge

Merge pairs of lists into one sorted list by comparing their front items and taking the smaller one each time.
StageLists
Single items6 | 2 | 8 | 4 | 7 | 1 | 5 | 3
Merge into pairs2, 6 | 4, 8 | 1, 7 | 3, 5
Merge into fours2, 4, 6, 8 | 1, 3, 5, 7
Final merge1, 2, 3, 4, 5, 6, 7, 8

Choosing an algorithm

Comparing algorithms means asking: how fast is it, how much memory does it need, and how easy is it to write and check?
ItemBubble sortMerge sort
Ease of codingVery easyHarder
Speed on large listsSlowMuch faster
Extra memoryNone neededNeeds extra memory for the merged lists
Best forSmall or nearly sorted listsLarge lists
Worked example

Merge the sorted lists 2, 5, 9 and 3, 4, 8 into one sorted list.

  1. Compare 2 and 3: take 2.
  2. Compare 5 and 3: take 3. Compare 5 and 4: take 4.
  3. Compare 5 and 8: take 5. Compare 9 and 8: take 8.
  4. Only 9 is left: take it.

Answer: 2, 3, 4, 5, 8, 9

Key idea

Merge sort splits a list into single items, then merges them back in order. It is faster than bubble sort on large lists but harder to code and uses more memory. Choose an algorithm by speed, memory and simplicity.

Key words
Merge sort
A divide and conquer sort that splits a list into single items, then merges them back together in order.
AND
A Boolean operator that gives True (1) only when both inputs are True.
Algorithm
A precise set of step-by-step instructions to solve a problem or complete a task.
Bubble sort
A sort that compares neighbouring pairs and swaps them if they are in the wrong order, making passes until no swaps are needed.
List
A data structure that stores many items under one name, in order, such as scores = [4, 7, 2].

All KS3 Computing key terms and definitions →

Common mistakes
Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. Merge 2, 5 and 3, 8 into one sorted list. Separate the numbers with commas.

    Show the answer

    Answer: 2, 3, 5, 8

    Compare the first items each time and take the smaller: 2, 3, 5, 8.

  2. Merge 2, 6, 11 and 4, 9 into one sorted list. Separate the numbers with commas.

    Show the answer

    Answer: 2, 4, 6, 9, 11

    Compare the first items each time and take the smaller: 2, 4, 6, 9, 11.

Check you have got it

Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.