void sort(int values[], int n)
{
int sorted;
do
{
sorted = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < i; j++)
{
if ((values[j]) > (values[j+1]))
{
int swap = values[j];
values[j] = values[j+1];
values[j+1] = swap;
sorted++;
}
}
n = n - 1;
}
// Prints ints to screen for debugging
for(int a = 0; a < n; a++)
{
printf("%i\n", values[a]);
}
}
while (sorted != 0);
return;
}
When the values are printed , they do not appear to have been sorted. Is this because my printf function is in the wrong place and they are printing to screen before the sort has occurred, or are no swaps taking place and my bubble sort isn't working?