You need to sign in to do that
Don't have an account?
:) :) :) :) :)
Shuffle or Randomize a List
How can I shuffle a List Collection in APEX.
Ex: List<Account> acc = new List<Account>({Acc1, Acc2, Acc3,....,AccN});
acc.shuffle(); or acc.random(); // I want something that shuffle or randomize the primitive or sobject data inside the list.
output should be ==> {Acc2048, Acc179, Acc8632,.....,AccN}
Thanks in advance.
Hello,
There is no random/shuffle method in apex but we can make use of random methid of maths class and can get a random number like in the below link:
http://wordgraphs.com/post/2303/Getting-random-number-in-Salesforce-Apex
http://stackoverflow.com/questions/14203851/salesforce-com-apex-test-class-issue-need-to-hard-code-opportunity-custom-field