Sorting function cleanup

Clean up some sorting function stuff including MinGW fix, common
function pointer type for comparison, and basic insertion sort
implementation.