Select the principle of sorting:
First trip: 0 The foot mark is compared with the following keywords, if the keyword is less than the 0-pin keyword, then the location of two keywords is exchanged; After the first simple selection of sorting, the 0 pin is the smallest record in all keywords.
Second trip: 1 The foot mark is compared with the following keywords, if the keyword is less than the 1-pin keyword, the location of the two keywords is exchanged; After a second pass, a simple selection is ordered, and the 1-foot mark is the smallest record in any other keyword except the 0-foot-key keyword.
.
.
And so on
.
.
Code implementation:
public class Select Sort { public static void main (String[] args) { int []a=new int[ ]{56,34,21,45,75,24,1,1,5}; print (a); //int []b=new int[a.length]; Choosesort (a); print (a); } public static void choosesort (int a[]) { for (int i=0;i<a.length;i++) { for (int j=i+1;j< a.length;j++) { &nBsp; if (A[i]>a[j]) { int m; m=a[i]; a[i]=a[j ]; a[j]=m; } continue; } }&nBsp; } public static void print (int a[]) { for (int x=0;x<a.length;x++) { if (x!=a.length-1) system.out.print (a[x]+ ","); else System.out.print (A[x]); } //return int; system.out.println (); }}
Implementation of the "Java" selection sort