1 void selectionSort(double list[], int arraySize) 2 { 3 for (int i = 0; i < arraySize - 1; i++) 4 { 5 // Find the minimum in the list[i..arraySize-1] 6 double currentMin = list[i]; 7 int currentMinIndex = i; 8 9 for (int j = i + 1; j < arraySize; j++) 10 { 11 if (currentMin > list[j]) 12 { 13 currentMin = list[j]; 14 currentMinIndex = j; 15 } 16 } 17 18 // Swap list[i] with list[currentMinIndex] if necessary; 19 if (currentMinIndex != i) 20 { 21 list[currentMinIndex] = list[i]; 22 list[i] = currentMin; 23 } 24 } 25 }