There is a great similarities between sorting and Bubble sorting. The final position of an element can be determined after a traversal. The main idea is to select the smallest element and the first element for one traversal, in this way, the elements are ordered, and then the second small element is selected to exchange with the second element. Knowing that there is only one element left, the largest element is displayed. At this time, the sorting is complete.
The Code is as follows; eclipse 4.3 jdk1.6
<AnyType Comparable <? AnyType> minIndex = 0 (a =) | (. length = 0 (I = 0; I <. length; I ++ minIndex = I; (j = I + 1; j <. length; j ++) {(a [j]. compareTo (a [minIndex]) <0 minIndex = (minIndex! = I) {temp = a [I] = a [minIndex] = Random rand = Integer [] arr = Integer [10 (I = 0; I <10; I ++ arr [I] = rand. nextInt (1000}
J. Continue to work