It's a little late for me to throw my brain into it, so I'll just show you what I use.
Code:
template <class number>
unsigned partition(number section[], unsigned start, unsigned finish, bool (*compare)(number, number) = greater)
{
unsigned pivot = start;
number value = section[pivot];
for( unsigned index = start + 1; index < finish ; ++index )
if( !compare( section[index], value ) )
swap(section[index], section[++pivot]);
swap(section[start], section[pivot]);
return pivot;
}
template <class number>
void quicksort(number section[], unsigned start, unsigned finish, bool (*compare)(number, number) = greater)
{
if(start < finish)
{
unsigned pivot = partition(section, start, finish, compare);
quicksort(section, start, pivot, compare);
quicksort(section, pivot + 1, finish, compare);
}
return;
}
template <class number>
void quicksort(number section[], unsigned length, bool (*compare)(number, number) = greater)
{
quicksort(section, 0, length, compare);
}