Direct Select sort
A. The 1th trip from which to find the smallest, with R0 exchange
B. 2nd trip Find the smallest from the remainder, with the R1 exchange
........................................................
The code is as follows
 
Directly select sort void selectsort (int []a,int N) { //define variable int i, J, Nminindex; for (i=0;i<n;i++) { //min. flag bit nminindex = i; Loop find minimum for (j=i+1;j<n;j++) { //Compare if (A[j] < A[nminindex]) { //if less than, Flag bit Change nminindex = j; } } After the above loop find the minimum if (nminindex!=i) { ///value to exchange int c = a[i]; A[i] = A[nminindex]; A[nminindex] = c;}} }
bubble vs. Direct selection sort comparison
In fact, the direct selection of the sort is much like bubble sort, but it is better than bubbling is not always bubbling, that is, the data exchange, but the bubble is better than it is that, if the order is already in place, you can directly stop
Direct Select sort