i wrote a function that uses a selection sort to sort an array of 25 integers. it calls a swap function i also wrote that swaps the integers. i compiled my code but it is not sorting the array correctly
void selectionSort( int numbers[ ], int list_size )
{
int unsorted; //size of unsorted list set to size of list
int temp; // temperorary space for integers
int count; // index for position in loop
int pos_max; // position of maximum value in array
// loop to start sort
for( unsorted = list_size; unsorted > 1; unsorted-- )
{
pos_max = numbers[0];
for( count = 1; count < list_size; count++ )
{
if( numbers[count] > pos_max )
{
swap( numbers[count], pos_max );
}
}
}
}
swap function
1 2 3 4 5 6 7 8
void swap( int *num1, int *num2 )
{
int temp; // temperorary variable
temp = *num2;
*num1 = *num2;
*num2 = temp;
}