Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting ARRAY
#1
I have an array that has been sorted like this:
Code:
Copy      Help
arr[0]=|000||data000a||data000b|
arr[1]=|000||data001a||data001b|
arr[2]=|000||data002a||data002b|
arr[3]=|001||data003a||data003b|
arr[4]=|001||data004a||data004b|
arr[5]=|001||data005a||data005b|
arr[6]=|002||data006a||data006b|
arr[7]=|002||data007a||data007b|
arr[8]=|002||data008a||data008b|

I want to keep the initial sets ("|000|" "|001|" "|002|" etc) in order but randomize within those sets.
One result could look something like this:
Code:
Copy      Help
arr[2]=|000||data002a||data002b|
arr[1]=|000||data001a||data001b|
arr[0]=|000||data000a||data000b|
arr[4]=|001||data004a||data004b|
arr[3]=|001||data003a||data003b|
arr[5]=|001||data005a||data005b|
arr[7]=|002||data007a||data007b|
arr[8]=|002||data008a||data008b|
arr[6]=|002||data006a||data006b|

In the end I need an array populated with the random list.

I've written some code that does it, but it is ever so messy using RunTextAsFunction. I could post, but it's probably not worth it unless you want to see how it works to help better understand in case my explanation isn't clear.

I'm guessing that using the callback function for array.sort is the way to go, but I have no idea.

Thanks,
jimmy Vig


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)