Bill Dewitt <bde### [at] cflrrcom> wrote:
> I've been trying to do a simple sort, but it doesn't seem to be working as
I
> remember. What am I doing wrong?
[code snipped]
The mistake comes in trying to use the First and Second variables as if they
were pointers (i.e. your code assumes modifying these two variables will
modify the original array members you declared them to). If you change the
code not to use these variables:
#declare I = 0; #while ( I < 5 )
#declare P = I+1; #while (P < 5)
#if (Spread[P] < Spread[I])
#declare Storage = Spread[I];
#declare Spread[I] = Spread[P];
#declare Spread[P] = Storage;
#end
#declare P = P+1; #end
#declare I = I+1; #end
you should find it works as expected.
Post a reply to this message
|