Merge sort
to continue. (After that any entries made into the worksheet will be automatically saved, and you can re-load the partially-completed worksheet in future - at which point you will be asked to auto-save it again).

Preliminaries

Step 1: Getting started

From the Demo menu, access the Merge sort code, then select File > Auto Save and complete the dialog to ensure that your code is always saved. Remember that you can use the Undo button (or Ctrl-z) to undo recent changes.

Note that the code contains two functions: sort and merge, plus two tests - one to test each function - with both tests covering multiple test cases (assert instructions). The asserts in test merge are all showing pass because the implementation of the merge function is complete and correct. The asserts in test sort are all failing with the message: actual: [x]. Looking at the code for the sort it is not hard to see why: this is merely a 'skeletal' implementation: sufficient code only to compile, not to run correctly. Your task is to implement sort properly, until all the tests pass. Your implementation should:

Hint 1: Recursion
Hint 2: Getting started
Hint 3: Description of the algorithm
Hint 4: Some useful coding idioms and hints
Hint 5: Suggested structure
Hint 6: First fields shown
Hint 7: Method calls shown
Hint 8: The complete solution
Total hints used: /
Worksheet completed.
This worksheet is copyright © Richard Pawson 2025, and protected by the Creative Commons license: Attribution-NonCommercial-NoDerivatives 4.0 International. If you copy and modify this worksheet you may not distribute your modified version (outside your own teaching institution) without the author's permission. Please email the author to report errors or suggest improvements.