I have ArrayList of Strings. I need to randomize it by “hash number”.
Example:
ArrayList: “Word”, “Simple”, “Another”, “Demo”
hash: 1234567
As a result of randomizing I want to receive say: “Simple”, “Word”, “Demo”, “Another”
with other hash: 542345 I want to receive say: “Word”, “Another”, “Demo”, “Simple”
But the requirements is that that when I always sort by this hash the randomizing order will always be THE SAME for that HASH.
Any suggestions? Adviscs?
You can shuffle a List using a Random object that you initialize with the hash.
When the same hash is used to seed the Random object, the shuffle order should turn out the same.