/*** Choose the idea of sorting:* Before each cycle, the left side of the array is partially orderly sequence,* then select the element on the right to save the value, and the value of its value is compared with the elements that have been ranked on the left. The element smaller than the left will move the element on the left to the right to compare with the leftmost side, or the element to be arranged is not as small as the left element small*/ package al; the public class design {INSERTIONSORT Insertsort = New Insertionsort (); int [] Elements = {14, 77, 21, 10, 50, 43, 14}; // sort the array insertsort.sort (elements); // PRINT The S Orted Array For (int i = 0; I <elements.length; i ++) {system.out.print (elements [i]); System.out.print ("");} /** * @param array Array*/ Public Void Sort (int [] array) {// Min to Save the Minimum Element for Each Round Int key; // Save Current Element for (INT I = 0; I <Array.Length; I ++) { int j = i; // Current position key = Array [j]; // Compare Current Element While (j> 0 && Array [j-1]> key) {Array [j] = Array [j-1]; / /shift it j-;} Array [j] = key;}}}