11 template<
class CONTEXT,
class TYPE>
12 static void insertion_sort(TYPE *elements,
size_t element_count, CONTEXT context,
int(*cmp)(CONTEXT context,
const TYPE *a,
const TYPE *b))
15 for (i = 1; i < element_count; i++)
17 TYPE value = elements[i];
18 for (j = i; j > 0 && cmp(context, &value, &elements[j - 1]) < 0; j--)
19 elements[j] = elements[j - 1];