Figure 7: Comparing iterator based sorting using <algorithm> with regular MFC sorting on an array of ints

// sorting the MFC way (many lines and ugly typecasted 
// comparison function)
int CompareUInts(const void *pv1, const void *pv2)
{
   return *(unsigned int*)pv1 - *(unsigned int*)pv2;
}
void mfc_sort(CUIntArray &arr)
{
   qsort(arr.GetData(), arr.GetSize(), sizeof(unsigned int), 
         CompareUInts);
}

// sorting the mfciter way (1 line)
void mfciter_sort(CUIntArray &arr)
{
   std::sort(mfciter::begin(arr), mfciter::end(arr));
}