Efficient implementations of Quicksort are not a stable sort, meaning that the relative order of equal sort items is not preserved. develop by British computer scientist Tony Hoare in 1959 and published in 1961, it is still a normally used algorithm for sorting. Robert Sedgewick's Ph.D. thesis in 1975 is considered a milestone in the survey of Quicksort where he resolved many open problems associated to the analysis of various pivot choice schemes including Samplesort, adaptive partitioning by Van Emden as well as derivation of expected number of comparisons and swaps. Jon Bentley and Doug McIlroy integrated various improvements for purpose in programming library, including a technique to deal with equal components and a pivot scheme known as pseudomedian of nine, where a sample of nine components is divided into groups of three and then the median of the three medians from three groups is choose. In the Java core library mailing lists, he initiated a discussion claiming his new algorithm to be superior to the runtime library's sorting method, which was at that time based on the widely used and carefully tuned variant of classic Quicksort by Bentley and McIlroy.

Recursively use the above steps to the sub-array of components with smaller values and separately to the sub-array of components with greater values. The pivot choice and partitioning steps can be done in several different ways

```
#include <stdlib.h>
#include <stdio.h>
void swap(int *a, int *b)
{
int tmp = *a;
*a = *b;
*b = tmp;
}
int partition(int arr[], int low, int high)
{
int pivot = arr[low];
int i = low - 1, j = high + 1;
while (1)
{
/* Find leftmost element >= pivot */
do
{
i++;
} while (arr[i] < pivot);
/* Find rightmost element <= pivot */
do
{
j--;
} while (arr[j] > pivot);
/* if two pointers met */
if (i >= j)
return j;
swap(&arr[i], &arr[j]);
}
}
void partitionSort(int arr[], int low, int high)
{
if (low < high)
{
int value = partition(arr, low, high);
partitionSort(arr, low, value);
partitionSort(arr, value + 1, high);
}
}
void printArray(int arr[], int n)
{
int i;
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
printf("\n");
}
int main()
{
int arr[20];
int i, range = 100;
for (i = 0; i < 20; i++)
{
arr[i] = rand() % range + 1;
}
int size = sizeof arr / sizeof arr[0];
printf("Array: \n");
printArray(arr, size);
partitionSort(arr, 0, size - 1);
printf("Sorted Array: \n");
printArray(arr, size);
return 0;
}
```