This is suppose to be a simple selection sort but I think I'm missing something because my output isn't completed sorted right.
void SelectionSort(data list[], int length)
{
int index;
int smallestIndex;
int minIndex;
data temp;
for( index = 0; index < length; index++)
{
smallestIndex = index;
for(minIndex = index + 1; minIndex < length; minIndex++)
{
if( list[minIndex].stateCity < list[smallestIndex].stateCity)
{
smallestIndex = minIndex;
temp = list[smallestIndex];
list [smallestIndex] = list[index];
list[index] = temp;
} // end if
} // end for loop with minIndex
} // end for loop index
} // end function SelectionSort
output is AZ, CA, CA, CA, FL, DC, etc. it skips every two or three and throws one out of order.
Can anyone figure out what is missing. I think it has something to do with the minIndex.