Efficient method to sort a CPtrarray?

What is the Efficient method to sort a CPtrarray in c++?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use qsort... as described here:
    How to use the quick-sort function to sort MFC CArray-derived classes on the MFC and Visual C++ run-time library

You will of course need to sort not on the *value* of the pointer itself, but on the value of the data to which each item points.  You write that logic into your Compare() function.

-- Dan

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

It depends on what you mean by efficient and a good deal on the type of data. For example, if most of the values are the same except just a few or most of them are already sorted then, believe it or not, bubblesort would be your best bet, with the normal tuning techniques.

Tell us a bit more about the data. Whats in it? How much does it vary? Can you add them one-at-a-time or do you get them in one big block? Etc ...

AndyAinscowFreelance programmer / ConsultantCommented:
What is efficient.
The bubble sort is very easy to code but takes a lot of time to sort compared to more advanced techniques.
However, if the array has, say, 8 pointers would the end user really notice it takes 0.001 seconds longer to execute?

(Bubble sort is just go through the array and swap adjacent items if they are not in order.  You keep doing that until no swaps are made.)
XPUSRAuthor Commented:
Thanks for the suggestions. How about conveting it to a vector and using the stl sort. How does this compare? The data in an array of stock performances.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.