How can I pick 20 Random Data from Firebase?
I think this will work well:
- Get all the tags from Firebase as a list. Let the list be X items long.
- Create a new empty list Y (this will be the final list of 20 data items)
- Run a loop 20 times
- In each iteration of the loop, pick a random
nnumber between 1 and X.
- Get the
nth element in your list of all tags.
- Add this element to list Y.
- Remove that element from the list of all tags.
- Decrement X by 1.
Hope this helps!
In that case, your program gets 20 random tags from FireBase DB. Get values paired with those tags using this block
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.