POV-Ray : Newsgroups : povray.general : Sort : Re: Sort Server Time
8 Aug 2024 12:24:53 EDT (-0400)
  Re: Sort  
From: Chris Colefax
Date: 1 Jan 2001 17:58:11
Message: <3a510b83@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.