I have created a Templated Heap Class and have managed to sort the list in ascending order through the use of a custom iterator class, i was just wondering how i would sort it in reverse order.
template <typename T>
inline void Heap<T>::sort_heap(DynamicArrayIter<T> first, DynamicArrayIter<T> second) {
int size = 0;
for (DynamicArrayIter<T> iter = first; iter != second; ++iter) {
size++;
}
T temp;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size - 1; j++) {
if (contents.at(j) < contents.at(i)) {
temp = contents.at(i);
contents.at(i) = contents.at(j);
contents.at(j) = temp;
}
}
}
}
Thanks,Soz could not get code insert to work...