QuickSort

Login to reply to this topic.
Fri, 2005-04-29 09:37
Joined: 2005-02-21
Forum posts: 47
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 Wink

Where am I wrong?

Ahti.

Wed, 2005-05-04 09:47
Joined: 2005-02-21
Forum posts: 47
QuickSort
yet another self-answer:
use RPointerArray and it's Sort method ... much easier and work correctly Smiley

Ahti.
  • Login to reply to this topic.