|
-
May 24th, 2009, 09:51 AM
#6
Re: VB6: All purpose sort
 Originally Posted by Merri
As for efficiency, Sort would call a case specific function once it has detected the format of the variable. Since it receives a Variant you can check for the VarType and work from there.
That's going to be quite a bit of code sprawl. Figure you need three copies of the algorithm for a single implementation: The basic algorithm for single dimension arrays, plus two copies for two-dimensional arrays to support column definitions in either the first or second dimension. (I don't even want to think about three-dimensional, much less n-dimensional arrays. Gah!)
If you want a separate implementation for each native type:
String
Byte
Integer
Long
Single
Double
Currency
Date
(Let's ignore boolean)
That's 8 different implementations, 3 copies of the algorithm per implementation.
If Radix sort is the best algorithm for all possible starting conditions: already sorted, inverse ordered, camel hump (quicksort killer), random, 5% shuffled, etc..., then it's ideal. A mere 24 copies of Radix sort later and you're done.
Is Radix sort the best algorithm for all starting conditions and all list sizes? If not, every change gets multiplied by 24 copies of the code.
I'm happy to be corrected, because I'm not a huge fan of code sprawl.
Just for the account both Å and Ä are always != A (in Swedish/Finnish they come after Z as ÅÄÖ  .
I overstated my point when I said they are all equal, but they only come after Z in a binary sort. Surely if you open up a Finnish dictionary you won't find Å alphabetized after Z.
Last edited by Ellis Dee; May 24th, 2009 at 09:55 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|