This bubble sort isnt working for me, any ideas? Im trying to sort a structure of arrays by one variable in structure. Im trying to sort by videocat.
for (j = 0; j < i - 1; j++)
for (x = i -1; x > j; --x)
if (VideoData[x-1].videocat < VideoData[x].videocat)
{
tmp = VideoData[x-1];
VideoData[x-1] = VideoData[x];
VideoData[x] = tmp;
}
for (j = 0; j < i - 1; j++)
printf("%-9.9s %-16.16s %-12.2s %-10s %-14.2f %c\n", VideoData[j].videonumber, VideoData[j].videotitle, VideoData[j].videocert, VideoData[j].videocat, VideoData[j].dailyrental, VideoData[j].available);