# Simple Quick Sort

In the previous challenge, you wrote a 'partition' method to split an array into smaller and greater elements. This means you 'sorted' half the array with respect to the other half. Can you repeatedly use 'partition' to sort an entire array?

Guideline: In Insertion sort, you simply went through each element in order and inserted it into a sorted sub-array. In this challenge, you cannot focus on one element at a time, but instead must deal with whole sub-arrays. Each time you call partition, you are sorting two parts of the array with respect to each other. Notice if you called partition on two elements, that sub-array would be fully sorted.
Can you repeatedly call partition on each sub-array so that the entire array ends up sorted?

### Challenge

Can you code a Quicksort algorithm?

Alternatively, you can try out Learneroo before signing up.

• #### mike

``````static void doStuff(int[] ar){
int pivot = ar;
int pivotLocation = 0;
for(int i = 1; i < ar.length; i++){
int curr = ar[i];
if(curr < pivot){
``````
• #### mike

static void doStuff(int[] ar){
partition(ar, 0, ar.length - 1);
}

``````static void partition(int[] ar, int min, int max){
int pivot = ar[min];
``````