Skip to content

Instantly share code, notes, and snippets.

@gamalielhere
Created May 9, 2017 04:57
Show Gist options
  • Save gamalielhere/e0dbacd79181a64a684d4e8ed8f7ada3 to your computer and use it in GitHub Desktop.
Save gamalielhere/e0dbacd79181a64a684d4e8ed8f7ada3 to your computer and use it in GitHub Desktop.
void selectionSort (int array[], int size) {
int startScan, minIndex, minValue;
for(startScan = 0; startScan < (size - 1); startScan++) {
minIndex = startScan;
minValue = array[startScan];
for(int index = startScan + 1; index < size; index++) {
if(array[index] < minValue) {
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment