Sorting alpha lists wierdness
Hi everyone,
I'm writing a utility to clean up emails and I need to sort a list of up to about 40000 items.
At first I tried putting these items in a sorted listbox this worked well, but then I noticed the list was like this:
AB
AB
AB
ab
ab
ab
AB
ABC
etc..
Where uppercase/lowercase of the same characters were mixed together. I did a bubble sort which corrects this but is super slow. I did a shell sort and quick sort and it is very fast but sorts similarly to the listbox sort. (upper and lower mixed)
I trimmed the strings before putting them in an array, so they are all of the same length.
What am I doing wrong?
thanks for your help!
m.
Re: Sorting alpha lists wierdness
If you put a UCase or an LCase on the List1.Additem entry as you were adding it, then when they got to your listbox that issue would not be present.
Re: Sorting alpha lists wierdness (RESOLVED)
Hey Hack,
That does work, but I need the data in the original format.
I stumbled on the solution.
Here's what I'm doing
1) place unsorted data in an array
2) sort the array (using bubblesort or other)
3) place array elements in a list box
If the listbox has sorted = true it sorts as I stated above. If sorted = false they are sorted perfectly. I have no idea why this would be, I assumed the sort routines were to blame, they worked perfectly.
It would be cool if someone could explain why this works this way, but I got by the problem....
m.