The function parameter has a pointer type
void sort(int* arr){
Even if you will rewrite the function declaration like
void sort( int arr[10] ){
nevertheless the compiler will adjust the function parameter having the array type to pointer to the element type as it is written in your original function declaration
void sort(int* arr){
And in this call of the function
sort(numbers);
the array designator is implicitly converted to a pointer to its first element. That is the call above in fact is the same as
sort( &numbers[0] );
So using the operator sizeof
with a pointer expression yields the size of a pointer. That is this line
//get the size of this array
int size=sizeof(arr)/sizeof(arr[0]);
is equivalent to
//get the size of this array
int size=sizeof( int * )/sizeof( int );
and yields either 2 or 1 depending on the used system.
You need to declare the function like
void sort( int *arr, size_t n );
and pass to the function the number of elements in the array explicitly.
Bear in mind that in general the user can use the function for a dynamically allocated array.
Pay attention to that the used by you algorithm is not the insertion sort algorithm. It is the selection sort algorithm with redundant swaps.
A function that implements the insertion sort algorithm can look for example the following way as it is shown in the demonstration program below.
#include <stdio.h>
void insertion_sort( int a[], size_t n )
{
for ( size_t i = 1; i < n; i++ )
{
int current = a[i];
size_t j = i;
for ( ; j != 0 && current < a[j - 1]; j-- )
{
a[j] = a[j - 1];
}
if ( j != i ) a[j] = current;
}
}
int main()
{
int a[] = { 9,8, 7, 6, 5, 4, 3, 2, 1, 0 };
const size_t N = sizeof( a ) / sizeof( *a );
for (size_t i = 0; i < N; i++)
{
printf( "%d ", a[i] );
}
putchar( '\n' );
insertion_sort( a, N );
for (size_t i = 0; i < N; i++)
{
printf( "%d ", a[i] );
}
putchar( '\n' );
}
The program output is
9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9
As for the function that implements the selection sort algorithm then without redundant swaps it can look the following way as it is shown in the next demonstration program.
#include <stdio.h>
void selection_sort( int a[], size_t n )
{
for ( size_t i = 0; i < n; i++ )
{
size_t min = i;
for ( size_t j = i + 1; j < n; j++ )
{
if (a[j] < a[min]) min = j;
}
if ( min != i )
{
int tmp = a[i];
a[i] = a[min];
a[min] = tmp;
}
}
}
int main()
{
int a[] = { 9,8, 7, 6, 5, 4, 3, 2, 1, 0 };
const size_t N = sizeof( a ) / sizeof( *a );
for (size_t i = 0; i < N; i++)
{
printf( "%d ", a[i] );
}
putchar( '\n' );
selection_sort( a, N );
for (size_t i = 0; i < N; i++)
{
printf( "%d ", a[i] );
}
putchar( '\n' );
}
The program output is the same as shown above
9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9