. 1 Package com.datastack.search; 2 . 3 Import java.util.Arrays; . 4 . 5 // selection sort . 6 public class SelectSort { . 7 public static void main (String [] args) { . 8 int [] = ARR new new int [] 5,3,2,54,5,1,23,5,3,2,3,1,5,65 { }; . 9 SelectSort (ARR); 10 . 11 System.out.println (of Arrays.toString (ARR) ); 12 } 13 // selection sort 14 public static void selectSort(int[] arr){ 15 for(int i=0;i<arr.length;i++){ 16 int minIndex=i; 17 for(int j=i+1;j<arr.length;j++){ 18 if(arr[j]<arr[minIndex]){ 19 minIndex=j; 20 } 21 } 22 if(i!=minIndex){ 23 int temp = arr[i]; 24 arr[i] = arr[minIndex]; 25 arr [minIndex] = temp; 26 } 27 } 28 29 } 30 }