void selectionSort(int data[], int count)
// selection sort function module in C
// Source: http://en.wikipedia.org/wiki/Selection_sort
// This code is licensed under the GNU Free Documentation License.
// It is from the Wikipedia article "Selection sort" dated 2006-11-07.
{
int i, j, min, temp;
for (i = 0; i < count - 1; i++) {
/* find the minimum */
min = i;
for (j = i+1; j < count; j++) {
if (data[j] < data[min]) {
min = j;
}
}
/* swap data[i] and data[min] */
temp = data[i];
data[i] = data[min];
data[min] = temp;
}
}
|