Sorting an array

C

Conrad Santiago

What is an efficient way to sort data in an array?

For example, I have a list of tasks and I want to apply macro commands to
these tasks sorted by Start Date. I'm assuming I'll need to store these
tasks into an array in order to sort them for use in the rest of the macro.
I'm just not sure whether I need to create a second array in which to store
the sorted tasks. Also, is it necessary to cycle thru each task a number of
times equal to the count of tasks to test each comparison?

This is more of a conceptual question. I'm just throwing it out there to
see what comes back. Thanks in advance for any responses.

Conrad Santiago
 
J

Jack Dahlgren

There are a number of commonly used sort algorithms.
This link provides an intro to many of them:
http://en.wikipedia.org/wiki/Sorting_algorithm

The bubble sort is not very efficient, but is one of the easiest to
implement.
You only need one variable to swap out into.

I think you may be able to avoid the sorting of an array if you set your
tasks collection the right way.
You can use the built-in sort in project prior to get a sorted list of tasks
if you like
Just sort the project by start date, then select all, then set your tasks
variable to the active selection.
You can then iterate through the tasks and assign them to an array (if
necessary) or just work on the collection.

-Jack Dahlgren
 
A

Abhijit

Not sure if you have solved this issue, but if you are using C++ then you can
use QSORT. I have successfully implemented it for sorting tasks as per my
requirements and it works very fast.

Abhijit
------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top