Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basShuffle(N2Shuff As Integer) As Variant
'Michael Red 7/25/02 Tek-Tips thread222-321406
Dim Shuf() As ShuffleType
Dim Idx As Integer
Dim Jdx() As Variant
Dim Sorted As Boolean
ReDim Shuf(N2Shuff)
ReDim Jdx(N2Shuff)
Idx = 1 'Easier for User & Can Use (0) for sorting
While Idx <= N2Shuff 'Add a Value to Shuffle and Its RELATIVE order
With Shuf(Idx)
.ToShuff = Idx
.ShuffOr = Rnd()
End With
Idx = Idx + 1
Wend
'Do any desired sort here. Sort the "TYPE" on the random Number
Idx = 1
Sorted = True 'Assume the BEST
While Sorted = True
While Idx <= N2Shuff - 1
Sorted = True 'Assume the BEST
If (Shuf(Idx).ShuffOr > Shuf(Idx + 1).ShuffOr) Then
'Swap
Shuf(0).ToShuff = Shuf(Idx).ToShuff 'Save Current
Shuf(0).ShuffOr = Shuf(Idx).ShuffOr
Shuf(Idx).ToShuff = Shuf(Idx + 1).ToShuff 'Move Next to Current
Shuf(Idx).ShuffOr = Shuf(Idx).ShuffOr
Shuf(Idx + 1).ToShuff = Shuf(0).ToShuff 'Move Saved to Next
Shuf(Idx + 1).ShuffOr = Shuf(0).ShuffOr
Sorted = False
End If
Idx = Idx + 1
Wend
Wend
Idx = 1
While Idx <= N2Shuff
Jdx(Idx) = Shuf(Idx).ToShuff
Idx = Idx + 1
Wend
'basShuffle = Jdx()
Idx = 1
While Idx <= N2Shuff
Debug.Print Idx, Jdx(Idx)
Idx = Idx + 1
Wend
End Function
for i = 0 to ubound(myArr,1)
myArr(i,0) = RND()
myArr(i,1) = -1
next
for i = 0 to ubound(myArr,1)
numHigher = 0
thisVal = myArr(i,0)
for j = 0 to ubound(myArr,1)
if thisVal > myArr(j,0) then
numHigher = numHigher + 1
elseif thisVal = myArr(j,0) then
myArr(j,0) = myArr(j,0) + .0000000000001
end if
next
numArr(i,1) = numHigher
next
for i = 0 to ubound(myArr)
myArr(i) = RND()
next
for i = 0 to ubound(myArr)
lowestVal = myArr(0)
lowestPos = 0
for j = 0 to uBound(myArr)
if myArr(j) < lowestVal then
lowestVal = myArr(j)
lowestPos = j
end if
next
myArr(lowestPos) = i + 1
next