Coding Quiz - Sort a List Using Quick Sort
The challenge for this coding quiz is to implement the quick sort
algorithm in Python.
You are tasked with writing a function that takes a list of arbitrary numbers as input, sorts it in ascending order using quick sort, and returns the sorted list.
Write Your Code
def solution(arr):
# Write your code here
return
Constraints
-
The input list will contain only numbers.
-
There are no restrictions on the size of the list.
-
You must use the standard implementation of quick sort (including pivot selection and partitioning).
Example Input/Output
-
Input:
[3, 6, 8, 10, 1, 2, 1]
-
Output:
[1, 1, 2, 3, 6, 8, 10]
-
Input:
[3, 1, 4, 1, 5]
-
Output:
[1, 1, 3, 4, 5]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.