1. Idea: in ascending order, each time you find the lowest subscript, and then swap with the current loop
2. Code
1 Public classTestarray {2 3 Public Static voidMain (string[] args) {4 int[] Array =New int[args.length];5 for(inti = 0; i < args.length; i++){6Array[i] =Integer.parseint (Args[i]);7 }8 9System.out.println ("before sorting");Ten for(intI:array) { OneSystem.out.print (i+ "\ T"); A } - -System.out.println ("\ n sort after"); the //Arrays.sort (array); - Testarray.selectedsort (array); - for(intI:array) { -System.out.print (i+ "\ T"); + } - } + A Public Static voidSelectedsort (int[] Array) { at for(inti = 0; i < Array.Length; i++){ - intindex =i; - for(intj = i; J < Array.Length; J + +){ - if(Array[index] >Array[j]) { -index =J; - } in } - if(i!=index) { to inttemp =Array[i]; +Array[i] =Array[index]; -Array[index] =temp; the } * $ }Panax Notoginseng } - the}
3.java Testarray 3 7 6 9 operation Result is
java-Selection Sorting method