Skip to Content
Merge Sort: Python
Finishing the Merge

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.

Folder Icon

Sign up to start coding

Already have an account?