Since we’ve only technically depleted one of our two inputs to merge(), we want to add in the rest of the values to finish off our merge() function and return the sorted list.



After our while loop, check if there are any elements still in left.

If there are, add those elements to the end of result.


After checking for elements in left let’s check if there are elements in right. If there are, add them to result.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?