To quickly sort an array of classes, create a single-dimensional
integer or real array of the same size, and populate it with values
that represent the desired sorting relationship. Then use .sortWith
For example, if myClass has 3 properties a,b and c, each from 0-99,
and I wanted to sort in ascending order of a,b and c, then I'd do
something like this:
Dim sortArray(-1) as Integer
redim sortArray(uBound(myClassArray))
for i = 0 to uBound(myClassArray)
sortArray(i) = 10000 * myClassArray(i).a + 100 * myClassArray
(i).b + myClassArray(c)
next i
sortArray.sortWith(myClassArray)
Integers are 4 bytes. I don't think you can sort with Int64s, I've
never tried. You can do it with reals (being careful to use values
that can be exactly represented, using only the 52 bit mantissa) or
with strings (much slower)
I find sortWith to be extremely handy for this kind of thing.
R
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>