Any thoughts on an efficient method to 'shuffle' or randomize a List collection?
i.e.
0,1,2,3,4,5,6,7,8,9
after shuffle (randomizing)
5,8,6,1,4,9,0,2,7,3
i.e.
0,1,2,3,4,5,6,7,8,9
after shuffle (randomizing)
5,8,6,1,4,9,0,2,7,3
' randomize a list of items in a list Global list:TList=CreateList() Type foodtype Field name$ Field price# Function Add(n$,p#) Local f:foodtype=New foodtype f.name$=n$ ; f.price=p ListAddLast list,f End Function Function ShowList() Print "----------------------" For Local f:foodtype=EachIn list Print f.name$+" - "+f.price Next End Function Function RandList(numtimes=3) For Local n=1 To numtimes For Local f:foodtype=EachIn list If Rnd()>0.3 ListRemove list,f ListAddLast list,f EndIf Next Next End Function End Type SeedRnd MilliSecs() Local f:foodtype f=New foodtype f.Add "pizza",2.50 f.Add "sausage",0.75 f.Add "pie",1.53 f.Add "onion",0.21 f.Add "soup",0.97 f.Add "crisps",0.29 f.ShowList Print "~nrandom ..." f.RandList f.ShowList End