Fast sorting of arrays in C language (including a detailed explanation of the algorithm)
Taking the array a [0] a [1] a [2] a [3] a [4] a [5] a [6] a [7] a [8] a [9] a [10] 032 39 23 45 36 57 14 27 39 as an example, the first round of the implementation mechanism of the core code is explained: first enter quickSort (a, 0,10) Key=0,i=0,j=10, enter the outer while, enter the first inner while, because 0 is the smallest in the array, so j sweeps all the way to the end of the array, jpend0Magi arr [0] = arr [0] = 0; obviously cannot enter the second inner while, because i=j=0 ends the outer while, execute a [0] = key=0; obviously does not enter the first if, enter the second if, execute quickSort (a, 1, 10) Sort from a [1] to a [10], and the first round ends. In the second round, execute quickSort (a, 1, 10), key=2,i=1,j=10, enter the outer while, enter the first inner while, because 2 is the smallest in the incoming segment, so j sweeps all the way to the head, Jaim1dagarr [1] = arr [1] = 2; obviously can not enter the second inner while, because i=j=1 ends the outer while, execute a [1] = key=2; obviously does not enter the first if, enter the second if, execute quickSort (a, 2, 10) Sort from a [2] to a [10], and the second round ends. The third round: execute quickSort (a, 2, 10), key=32,i=2,j=10, enter the outer while, enter the first inner layer while,a [10] = 39 > key=32,--j,j becomes 9 tera [9] = 27