Log in from a computer to take this course

You'll need to log in from a computer to start Learn Sorting Algorithms with Python. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

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?