1. Bubble sort: Compare before and after two adjacent elements, if greater than the exchange, so that each iteration of an array, the largest data sink to the N-1 position of the array.
Two kinds of improvements: a. If the current traversal does not occur, the interchange is already in order; b. Record the location of the last data exchange I, the data after this position is clearly already in order, then the next traversal only need to bubble the data before I.
voidBUBBLESORT3 (intA[],intN) { intJ, K; intFlag; Flag=N; while(Flag >0) {k=Flag; Flag=0; for(j =1; J < K; J + +) if(A[j-1] >A[j]) {Swap (a[j-1], a[j]); Flag=J; } }}
Bubble sorting is less efficient and can be used when the data is small.
2. Direct insertion sorting is the insertion of data into an already sequenced array, and the direct selection of the sort is to select a minimum from the array that is not sorted later, append to the previous sort.
http://blog.csdn.net/morewindows/article/details/6665714
Several sorting algorithms