The fast sorting method is an improvement to the bubbling sorting method. His basic idea is to divide the data into two separate parts, one by one, in which all of the data is smaller than the other, to sort the entire data.
First select a data as the Datum x usually selects the first data. Set two variables i,j start sorting i = 0 J = N-1 (here N is the number of data). Search from J, that is, search from backward forward, find the value less than X to Exchange. , then search from I, find a value greater than x Exchange both, cross-repeat the above two steps, until i = J;
As an example:
A[0] a[1] a[2] a[3] a[4] a[5]
49 38 65 97 76 13
To do the first sort:
Results after Exchange 13 38 65 97 76 49 at this time J = 4;
Second Order:
Results after Exchange 13 38 49 97 76 65 at this time i = 2;
Third Order:
Results after Exchange 13 38 49 97 76 65 at this time J = 2;
I = J Quick Sort ends. {13 38} 49 {97 76 65} achieves expected results
Fast sorting Method C language implementation