Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

How to randomly shuffle an array

Is there a way to randomly shuffle the elements of an array?

Comments

  • DA = "ONE":@FM:"TWO":@FM:"THREE":@FM:"FOUR":@FM:"FIVE" N = DCOUNT(DA, @FM) FOR I = N TO 2 STEP -1 J = INT(RND(I)) + 1 TEMP = FIELD(DA, @FM, I) DA = FIELDSTORE(DA, @FM, I, 1, FIELD(DA, @FM, J)) DA = FIELDSTORE(DA, @FM, J, 1, TEMP) NEXT I $debug
  • Thank you
  • How large of an array? I'm interested in both the number of elements and the length of the data in these elements.
Sign In or Register to comment.