Medium Sorting

Quicksort

Receives an array of integers and sorts it in ascending order using quicksort, a divide-and-conquer algorithm. For each range it picks a pivot (the last element) and partitions the range so that every value smaller than the pivot ends up to its left and every larger-or-equal value to its right; the pivot then sits in its final sorted position. The two sides are sorted the same way recursively until every range has at most one element. Returns a new array with the values in ascending order.

Visualization

Input

Algorithm code

Custom input

Saved inputs

References