Quick Sort

Advanced

Welcome to the Quick Sort challenge! Today, we'll be sorting some fun collections of numbers using a very clever method called quicksort! Quicksort is a popular and efficient way to arrange numbers from smallest to largest (or vice versa). It works by selecting a 'pivot' number and rearranging the other numbers into lists of 'less than' and 'greater than' numbers, before applying the process recursively.

Here's how you can approach this challenge:

  1. Pick a pivot number from your list (typically the first number or the middle one).
  2. Divide the list into two lists: numbers less than the pivot and numbers greater than or equal to the pivot.
  3. Recursively apply the quicksort process to these two smaller lists.
  4. Concatenate the sorted lists and the pivot in the middle, giving you the final sorted list.

Example:

quick_sort([3, 6, 8, 10, 1, 2, 1])

Output:

[1, 1, 2, 3, 6, 8, 10]

Remember, recursion means a function that calls itself. Make sure to have a base case for your recursive function, such as when the list has fewer than 2 elements! Now, let's sort those numbers with your very own version of quicksort.

Geek
Inputs

Arg 1:

[3,6,8,10,1,2,1]
Expected Output
[1, 1, 2, 3, 6, 8, 10]
Actual Output
Quick Sort [advanced] | Coding for Kids