I have some questions about selection sort.I\'m a little bit confused.
int [] arr = {5,4,3,2,1}; // This is my array
int min = 0;
for(int i = 0;i&l
pass the unsorted array get the sorted array
public int[] selectionSort(int[] list) {
int i, j, minValue, minIndex, temp = 0;
for (i = 1; i < list.length; i++) {
minValue = list[i];
minIndex = i;
j = i - 1;
for (j = i; j < list.length; j++) {
if (list[j] < minValue) {
minValue = list[j];
minIndex = j;
}
}
if (list[i] > minValue) {
temp = list[i];
list[i] = list[minIndex];
list[minIndex] = temp;
}
}
return list;
}