Challenge 3: Sort an Array

Given an array of numbers, sort it in increasing order.

Problem Statement

Implement a function that sorts the input array testVariable in-place.

In-place means that no extra array or any other data structure is used. Such algorithms produce an output in the same memory/space that contains the data by transforming the input in-place. However, a constant extra space can be used in the form of simple variables.

Remember to solve this problem recursively.

Input

  1. An array testVariable containing numbers.
  2. Length of the array

Output

No output. Our task is to sort the input array.

Sample Input

testVariable = [5, 4, 2, 3, 1]
length = 5

Sample Output

# No explicit output. 
# However the state of array testVariable is [1, 2, 3, 4, 5]

Try it Yourself

Try to attempt this challenge by yourself before moving on to the solution. Good luck!

Press + to interact
def sort(testVariable, length) :
# Write your code here
return None

In the next lesson, we have the solution review of this problem.