|
-
May 4th, 2000, 05:28 AM
#1
Thread Starter
Hyperactive Member
Does anyone have a code sample that will alphabetize a list? I am using a For Each loop to populate a list but the items all come out jumbled.
Here's what it looks like now:
Code:
For Each Animation In Merlin.AnimationNames
List1.AddItem Animation
Next
Can anyone help?
-
May 4th, 2000, 05:33 AM
#2
Well here's a simple process. Put the word in a Temp textbox. Get the first letter of the word. Since each character has a number value, arrange each word in order from which even "number" is the smallest.
For example, on the ASCII Chart, a = 97, b = 98 c = 99 d = 100 etc. etc.
-
May 4th, 2000, 05:51 AM
#3
Just change the Sorted property of the ListBox to True.
-
May 5th, 2000, 10:01 AM
#4
Conquistador
Code:
For Each AnimationName In Character.AnimationNames
ListBox.AddItem AnimationName
Next
and set it to sorted = true, for the listbox
-
May 6th, 2000, 03:10 PM
#5
Frenzied Member
how about for data arrays
Hey guys, I have a similar problem.
I made a small database that basically reads/write by a text file of the records. This kind of thing
For intX = 0 to intNumRecords
Write #1, strName(intX), strAddress(intX), strEmail(intX)...
Next intX
Question is: How can I alphabetize the strName() of a new
record that is being added to the file and keep all records of the index intX intact (in other words re-writing the entire file now alphabetized with name , address, ....etc.
still corresponding)?
Has anybody done this already?
Thanks .
-
May 6th, 2000, 05:48 PM
#6
transcendental analytic
I put my qwestion here
Does anyone know how listbox sorts? I have an app that use bubblesort but it goes exponentially slower, the more items i have. If anyone have a faster sorting method, like listbox, post back to me.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 6th, 2000, 06:09 PM
#7
Addicted Member
The fastest sorting algorithm is a Shellsort algorithm using a C++ DLL. you can use it e.g. to sort arrays.
The source for the C++ DLL is:
Code:
#include <windows.h>
/***********************************************************
shellsort algorithm
dllname : sort32.dll
parameters: array, fieldelementcount
***********************************************************/
void _stdcall sort(double a[], long n)
{
long k, i, j;
double hM
k = n/2
while (k>0)
{ for (i=0; i<n-k; i++)
{ j=i;
while (j>=0 && a[j]>a[j+k])
{ h=a[j]; a[j]=a[j+k]; a[j+k]=h; j=j-k; }
}
k = k/2;
}
}
BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
{ return TRUE; }
to use this routine in a VB program:
Code:
Declare Sub sort Lib "sort32.dll" (field as Double, ByVal count&)
[Edited by Razzle on 05-07-2000 at 07:12 AM]
Razzle
ICQ#: 31429438
What is the difference between a raven?
-The legs. The length is equal, especially the right one. 
-
May 6th, 2000, 06:25 PM
#8
transcendental analytic
Thanks, can anybody translate that to vb?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 6th, 2000, 06:48 PM
#9
Addicted Member
no problem
Code:
Sub sort_shell(a() as Variant)
Dim n&, i&, j&, k&, h as Variant
n = Ubound(a)
k = n \ 2
While k > 0
For i = 0 to n - k
j = i
While (j >= 0) And (a(j) > a(j + k))
h = a(j)
a(j) = a(j + k)
a(j + k) = h
If j > k Then
j = j - k
Else
j = 0
End if
Wend
Next i
k = k \ 2
Wend
End Sub
[Edited by Razzle on 05-07-2000 at 07:49 AM]
Razzle
ICQ#: 31429438
What is the difference between a raven?
-The legs. The length is equal, especially the right one. 
-
May 6th, 2000, 08:11 PM
#10
transcendental analytic
Thanx again, i was thinking, why only double, because i'm sorting strings. Now variant looks much better
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|