I have been running gdb on this, and it's true, the values are not sorted. But my logic seems fine. This is the selection sort, anyone know what I am missing? Thanks in advance.
int min, hold, i, j;
for (i = 1; i < (n - 1); i++)
{
min = i;
for (j = i + 1; j < n; j++)
{
if (values[j] < values[min])
min = j;
if (min != i)
{
hold = values[j];
values[j] = values[i];
values[i] = hold;
}
}
}
I got ideas for this code from the video Selection Sort: