HTML:
Hi ,
How can i shuffle string of array
alphabets = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
TO SOME RANDOM STATE LIKE
alphabets = {"C", "A", "I", "D", "G", "J", "H", "H", "B", "F"};
Hi ,
How can i shuffle string of array
alphabets = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
TO SOME RANDOM STATE LIKE
alphabets = {"C", "A", "I", "D", "G", "J", "H", "H", "B", "F"};
B4X:' Knuth's Algorithm P Dim n As Int = alphabets.Length Dim r As Int Dim t As String For i = 0 To n - 1 r = Rnd(i, n) t = alphabets(i) alphabets(i) = alphabets(r) alphabets(r) = t Next
Sub ShuffleArray(arr() As String)
Dim n As Int = arr.Length-1
Dim r As Int
Dim t As String
For i = 0 To n - 1
r = Rnd(i, n)
t = arr(i)
arr(i) = arr(r)
arr(r) = t
Next
Return arr
End Sub
ShuffleArray(YourArr)
Dim n As Int = arr.Length-1
Dim n As Int = arr.Length
For i = 0 To n - 1
For i = 0 To n - 2
Check out this thread https://www.b4x.com/android/forum/threads/sorting-algorithms-teaching-with-basic4android.8548/Any way to reverse this process?
take alphabets = {"C", "A", "I", "D", "G", "J", "H", "H", "B", "F"};
and arrange it back into alphabets = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};