QuickSort
| Fri, 2005-04-29 09:37 | |
|
Hi,
(I start to wonder why I have such a problems) Problem with a User::QuickSort. I want to sort an array containg pointers to some of my own CBase-derived objects. And I want to do a comparing by several fields in that array. Ok, I need a TKey-derived class which then compares necessary things. And also I inherit my list-class from TSwap to be able to swap items. User::QuickSort( <count>, mykey, *mylistobject ); What happens now is that at once the Swap() gets called with arguments to swap 1st and 2nd. Even no comparision has not be made yet. Really weird. After that I get several comparisions, including the ones to compare for example 2nd item with 2nd. Same goes for swap: swap 2nd with 2nd. Even more weird. Is that what we call an algorithm? Important to mention that the result is correct though but come on ppl, it's a phone and I don't have processor to waste on that extra comparision for a starter ![]() Where am I wrong? Ahti. |
|







Forum posts: 47
use RPointerArray and it's Sort method ... much easier and work correctly
Ahti.