[Solved] Insertion Sort is giving bizarre output [closed]


Your current method is … not quite right, for any kind of sort. Insertion sort would take an element and insert it at the correct index, then shift the already inserted items down appropriately. Something like

void looper(int *p)
{
    for (int i = 1;i < 25;i++)
    {
        int key = p[i];
        int j = i - 1;
        while (j >= 0 && p[j] > key)
        {
            p[j + 1] = p[j];
            j = j - 1;
        }
        p[j + 1] = key;
    }
}

solved Insertion Sort is giving bizarre output [closed]