function Shuffle(array as Object) as Void
for i% = array.count()-1 to 1 step -1
j% = Rnd(i% + 1) - 1 ' pick random j
t = array[i%] : array[i%] = array[j%] : array[j%] = t ' swap [i] with [j]
end for
end function
if sec.Read("shuffle") = "off"
m.audio.SetContentList(item)
end if
if sec.Read("shuffle") = "on"
m.audio.SetContentList(Shuffle(item))
end if
Function Shuffle(item As Object)
for i% = item.count()-1 to 1 step -1
j% = Rnd(i% + 1) - 1 ' pick random j
t = item[i%] : item[i%] = item[j%] : item[j%] = t ' swap [i] with [j]
end for
End Function
Function Shuffle(item As Object)
'for i% = item.count()-1 to 1 step -1
' j% = Rnd(i% + 1) - 1 ' pick random j
' t = item[i%] : item[i%] = item[j%] : item[j%] = t ' swap [i] with [j]
'end for
End Function
You made a mistake. It returns less (n-1) elements than the original array.