DaveS
(DaveS)
March 9, 2014, 9:29pm
#1
I have an array the needs to be sorted by A().LEFT and then within that A().RIGHT
this array can have 3-4 THOUSAND entires (depending)… basically it is a dictionary of words and page #'s
I have a “bubble” sort that does it… but it starts to slow down alot when you get into larger values.
Norman_P
(Norman P)
March 9, 2014, 9:46pm
#2
Radix sort which is stable
Before implementing your own algorithm, what about creating an index array like
index() = A().Left + Str( A().Right, "00000000" )
Then use SortWith?
DaveS
(DaveS)
March 10, 2014, 2:42am
#4
[quote=70295:@Kem Tekinay]Before implementing your own algorithm, what about creating an index array like
index() = A().Left + Str( A().Right, "00000000" )
Then use SortWith?[/quote]
dim xsort(-1) as string
for i=0 to index_data.Ubound
xsort.append index_data(i).left+"**"+index_data(i).right
next i
xsort.SortWith(index_data)
a bit more over head… but dang it it faster than any other method I tried…
I was just about to tell you that I tested this, and it came in at about 37 ms for 5,000 entries.
You have to use Format or Str with a format for the number, though. Otherwise you’ll get sorts like 1, 10, 11, 2.
DaveS
(DaveS)
March 10, 2014, 5:40am
#6
Yes… fortunatly my data was already formatted that way thank