Here I am implementing a simple sort (insertion), but I'm not getting the correct size of the array. Namely, my length variable is getting set equal to 1. Also, what ways could I optimize my code for this insertion sort algorithm? Thanks
void insertionSort(int a[])
{
    int sorted = 1;
    int length = sizeof(a) / sizeof(int);
    int i = 0;
    int tmp;
    printf("%d   ", length);
    if (length < 2)
        return;
    for (i = 1; i < length - 1; i++)
    {
        sorted = i;
        while (a[sorted] < a[sorted - 1] && sorted > 0)
        {
            tmp = a[sorted];
            a[sorted] = a[sorted - 1];
            a[sorted - 1] = tmp;
            sorted--;
        }
    }
}
 
     
     
    