我的书在 C 中实现了插入排序

my book's implementation of insertion sort in C

我想确切地知道第三个参数应该是什么,因为我从未见过类似的东西。

void sortPointers(void **ar, int n, int (*cmp)(const void *, const void *))
{
    int j;
    for (j = 1; j < n; j++)
    {
        int i = j - 1;
        int *value = ar[j];
        while (i >= 0 && cmp(ar[i], value) > 0)
        {
            ar[i+1] = ar[i];
            i--;
        }
        ar[i+1] = value;
    }
}

该参数是指向比较两个 void* 指针的函数的指针。 sortPointers(..) 函数的这种实现方式使其调用者可以使用任何比较函数,从而增加了灵活性。

http://c.learncodethehardway.org/book/ex18.html