' Adapted from a program by Anatoly Sheyanov (tsh73) randomize 0.5 N=15 dim a(N,2), r(N) for i = 0 to N-1 a(i,1)= int(i/5) a(i,2)= int(rnd(1)*5) r(i) = a(i,2) next print "by construction sorted by column #1" for i = 0 to N-1 print a(i,1), a(i,2) next sort a(), 0, N-1, 1 print print "After re-sorting by column #1" print "Check whether column #2 has changed" for i = 0 to N-1 print a(i,1), a(i,2), if i=0 then print else if a(i,2) <> r(i) then print "order changed" else print end if next
|
|
|