Write a class to encapsulate the individual elements, 'Name' and 'Email', then instantiate objects of this class and put them in the array. That way they'll stay together. However, Array.Shuffle works only on arrays of primitive data types (I believe...), not objects, so you'll need to write another class to contain the array, and let it do the shuffling (basically, a bubble-sort, but - instead of comparing elements to determine if they should be swapped - you just 'flip a coin' (i.e. use RBs RNG); this is usually how I handle shuffling cards code-wise.) via a 'Shuffle' method.

On Jul 8, 2006, at 12:01 PM, Stephen Dodd wrote:

Does anyone know a reasonable method to shuffle paired data?

For instance if I have 2 arrays:
dim Name(100) as string
dim Email(100) as string

I can't use name.shuffle and email.shuffle because they will no longer match.

If I use:
dim NameAndEmail(100, 1) as String
...
// populate
// NameAndEmail(x, 0) = Name
// NameAndEmail(x, 1) = Email
...

then
NameAndEmail.Shuffle

It appears to mix the dimensions together. That is email will appear in the name dimension randomly.

Or is this write a shuffle routine from scratch case?

Cheers!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to