>- Open Your Mind -<



I've been trying to make a multiple-key sorting routine for a block of objects and I 
had a couple of problems. Now the routine works, but I'm not completely satisfied with 
my solution and I'm still curious about the problems.


1.
As a first step, just to see the result, I began by sorting n times, least significant 
key first. This is a slow process, but it usually works. In this case, though, it 
didn't. It resulted in the block sorted by the most significant key only, ignoring the 
other keys.
I guess this has something to do with the inner workings of the sort function, but...


2.
OK, bypassing completely the quick and dirty solution, I wrote a sort-method function 
that does it all in one pass only, but it doesn't like local variables. I use a 
variable to store an intermediate result, but if I specify that variable as local, 
REBOL aborts after some iterations, yielding this:

> Invalid data type during recycle
> ** Press enter to quit.

The series to sort is a block of 59 objects (for now), sorted with something like this 
(which also aborts):

sort-method: func [a b /local c] [c: a/type < b/type c]
sort/compare database :sort-method

Is this a bug or just me missing something totally obvious? Garbage collection? 
Garbage in my mind?


For now, I've eliminated the /local refinement from the sort-method. :-(




Alessandro Pini ([EMAIL PROTECTED])

"I think I will stick my head in the station's fusion reactor. It would be quicker!" 
(Mollari)

Reply via email to