---
id: 6569b743630ee592a65a7e2f
title: Step 20
challengeType: 20
dashedName: step-20
---

# --description--

Before testing the `merge_sort()` function, you need to create a base case that stops the function execution when the length of `array` is less than or equal to `1`.

This base case will stop the recursion call. Without it, the merge sort operation would continue to run even when the list has been sorted or has no elements in it.

Right after the function declaration, create an `if` statement with this condition: `len(array) <= 1`. Within the body of the `if` statement add a `return` statement to stop the execution of the function.

# --hints--

You should create an `if` statement to check if `len(array) <= 1`.

```js
({
    test: () => assert(runPython(`
      _Node(_code).find_function("merge_sort").find_ifs()[0].find_conditions()[0].is_equivalent("len(array) <= 1")
    `))
})
```

You should have a `return` statement in the body of the `if` statement.

```js
({
  test: () => assert(runPython(`_Node(_code).find_function("merge_sort").find_ifs()[0].find_body().has_stmt("return")`))
})
```

# --seed--

## --seed-contents--

```py
--fcc-editable-region--
def merge_sort(array):
    
--fcc-editable-region--
   
    middle_point = len(array) // 2
    left_part = array[:middle_point]
    right_part = array[middle_point:]

    merge_sort(left_part)
    merge_sort(right_part)

    left_array_index = 0
    right_array_index = 0
    sorted_index = 0

    while left_array_index < len(left_part) and right_array_index < len(right_part):
        if left_part[left_array_index] < right_part[right_array_index]:
            array[sorted_index] = left_part[left_array_index]
            left_array_index += 1
        else:
            array[sorted_index] = right_part[right_array_index]
            right_array_index += 1
        sorted_index += 1

    while left_array_index < len(left_part):
        array[sorted_index] = left_part[left_array_index]
        left_array_index += 1
        sorted_index += 1
   
    while right_array_index < len(right_part):
        array[sorted_index] = right_part[right_array_index]
        right_array_index += 1
        sorted_index += 1
```
