question unsort(x)
- Posted by Salix <salix at ?reemai?.hu> Aug 05, 2007
- 546 views
It is not a typical thing but now I need a routine that is simple, fast, efficient and puts the elements of a sequence into random order. The best I could come up with is this.
function unsort(sequence x) integer lx,px,py object bx lx=length(x) bx=x[1] x[1]=0 py=1 for i=1 to lx by 1 do px=rand(lx) x[py]=x[px] py=px end for x[py]=bx return x end function
Any more efficient code? Any better idea? Thanks in advance! Salix