The code is as follows:
public class Insertsort {public static void Insertsort (Datawrap [] data) {System.out.println ("start sort:"); int length = The value of data.length;for (int i = 1;i < length;i++) {datawrap tmp = data[i];//i index is already larger than all values on that side, indicating that it is ordered, without inserting// (The data before the I-1 index is already ordered, the value of the element at the I-1 index is the maximum value) if (Data[i].compareto (data[i-1]) <0) {int J = i-1;//The whole moves back one block for (; J >= 0 & & Data[j].compareto (TMP) >0; j--) {data[j+1] = data[j];} Finally, the value of TMP is inserted in the appropriate position data[j+1] = tmp;} System.out.println (java.util.Arrays.toString (data));}} public static void Main (string[] args) {datawrap[] data = {new Datawrap (""), New Datawrap (""), new Datawrap (49, ""), New Datawrap (""), new Datawrap (+, ""), new Datawrap (9, ""), New Datawrap (-16, "")}; System.out.println ("before sorting: \ n" + java.util.Arrays.toString (data)); Insertsort (data); System.out.println ("After sorting: \ n" + java.util.Arrays.toString (data));}}
Java Insert Sort