//https://www.facebook.com/permalink.php?story_fbid=2750473708542571&id=100007399066161 //Subscribed by tharindu Rewatha class JavaExample { void selectionSort(int arr[]) { int len = arr.length; for (int i = 0; i < len-1; i++) { // Finding the minimum element in the unsorted part of array int min = i; for (int j = i+1; j < len; j++) if (arr[j] < arr[min]) min = j; /* Swapping the found minimum element with the first * element of the sorted subarray using temp variable */ int temp = arr[min]; arr[min] = arr[i]; arr[i] = temp; } } // Displays the array elements void printArr(int arr[]) { for (int i=0; i