Hi Howard,
I've taken a very quick look at a few of the routines, and it has prompted
me to ask a question. When sorting an array of strings, what mechanism are
you using to compare the strings?
In the routines I looked at, from the modSortHK.bas module, it appears that
you are doing a straightforward "if string1 > string2 Then" comparison.
The problem with this is that while it might be very fast, this method
doesn't necessarily give a sort order that is very useful. For instance, I
doubt that most people would expect the four items "bath", "Bath", "cattle",
"Cattle" to be sorted "Bath", "Cattle", "bath", "cattle". That is the sort
order which results from a straightforward string comparison. The
InsertionString routine in your modSortHK.bas module gives precisely this
sort order.
WordBasic.SortArray has a more sophisticated comparison mechanism that does
an alphabetic comparison, so that sort order for those four items is "bath",
"Bath", "cattle", "Cattle", which is much more what users might expect.
I'm therefore concerned that your performance comparisons might (quite
unintentionally) be misleading because they are not comparing algorithms
which have the same output.
If you want to produce a performance comparison of WordBasic.SortArray and
other algorithms, then it really is necessary to ensure that the other
algorithms produce the same output. In principle, this should not be too
hard to achieve. All that is required is that you write a suitable
CompareStrings routine, which returns a boolean value depending on the
relative position of two strings in a SortArray-style algorithm. Such a
routine could then by dropped into the various string sorting algorithms as
a direct replacement of the "string1 > string2" comparison you have now.
Your choice of string data for your comparison (i.e. strings containing only
numeric characters) masks the fact that different comparison algorithms are
being used.
It might be that even with a more sophisticated string comparison that these
other algorithms (Quicksort especially) might still be faster than
WordBasic.SortArray, but until you do a like-for-like comparison, there is
no way of knowing whether the apparent poor performance of
WordBasic.SortArray is due to an inefficient sorting algorithm or more
computer-intensive string comparison.
A further check might need to be made of the sorting algorithms in Excel
that you are including in the comparison, to see what sort order they
produce with a wider range of string input data.
--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup