# Quick sort analysis of c-sort algorithm

Time：2021-4-2

This example for you to share the C # to achieve quick sort of specific code, for your reference, the specific content is as follows

code:

``````/// <summary>
///Sort
/// </summary>
///< param name = "array" > array to sort < / param >
///< param name = "low" > start position of subscript, find right < / param >
///< param name = "high" > start position of subscript, find left < / param >
public static void Sort(int[] array, int low, int high)
{
if (low >= high)
return;
//Complete a cell sorting
int index = SortUnit(array, low, high);
//Recursive call, the left part of the array cell sorting
Sort(array, low, index - 1);
//Recursive call, the right part of the array cell sorting
Sort(array, index + 1, high);
}

/// <summary>
///Cell sorting
/// </summary>
///< param name = "array" > array to sort < / param >
///< param name = "low" > start position of subscript, find right < / param >
///< param name = "high" > start position of subscript, find right < / param >
///< returns > stop subscript of each cell sort
public static int SortUnit(int[] array, int low, int high)
{
Int key = array [low]; // benchmark number
while (low < high)
{
//Find the value less than or equal to key from high
while (low < high && array[high] > key)
high--;
//Smaller than key, left
array[low] = array[high];
//Find the value greater than key from low
while (low < high && array[low] <= key)
low++;
//Bigger than key on the right
array[high] = array[low];
}
//At the end of the loop, low equals high, the left is less than or equal to key, and the right is greater than key. Place the key in the current position of the cursor.
array[low] = key;
return high;
}``````

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.

## Collection

ArrayList uses array storage at the bottom The bottom layer of LinkedList uses a doubly linked list The bottom layer of HashSet is a HashMap support, and the bottom layer of HashMap physically implements a Hash table The bottom layer of LinkedHashMap is a data storage structure combined with a linked list and a hash […]