Java's simple sort includes: Insert sort, select sort, bubble sort, order sort. Now paste its code as follows:
public class Arrays {public static void main (string[] args) {int a[]=new int[]{7,6,5,4,3,2,1};//Insertsort (a);//
Bubblesort (a);
Selectedsort (a);
Print (a);
public static void print (int a[]) {for (int i=0;i<a.length;i++) {System.out.print (a[i]+ "");
} System.out.println ();
public static void Bubblesort (int a[]) {//bubble sort for (int i=0;i<a.length-1;i++) {for (int j=i+1;j<a.length;j++) {
if (A[i]>a[j]) {int temp=a[i];
A[I]=A[J];
A[j]=temp;
}}} public static void Selectedsort (int a[]) {//select sort for (int i=0;i<a.length-1;i++) {//up to a.length-1 trip sort
int min=i;
for (int j=i+1;j<a.length;j++) {if (A[j]<a[min]) {min=j;
} int temp=a[min];
A[min]=a[i];
A[i]=temp;
The public static void Insertsort (int a[]) {//Insert sort, can only take the overridden method int i,j;
for (i=1;i<a.length;i++) {int temp=a[i];
for (j=i;j>0;j--) {if (a[j-1]>temp) {a[j]=a[j-1];
}} a[j]=temp;
}
}
}
<span style= "Font-family:arial;background-color:rgb (255, 255, 255);" > Simple comparison of several sorts of:</span>
<span style= "Font-family:arial;background-color:rgb (255, 255, 255);" > Insert Sort: Generally, the most efficient;</span> in these sorts of categories
<span style= "Font-family:arial;background-color:rgb (255, 255, 255);" > select sort: Reduces the number of exchanges relative to bubble sort;</span>
<span style= "Font-family:arial;background-color:rgb (255, 255, 255);" > Bubble Sort: simplest, but relatively inefficient </span>