Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Help with sorting/randomizing?by druthb (Beadle) |
on Mar 25, 2012 at 19:42 UTC ( [id://961529]=note: print w/replies, xml ) | Need Help?? |
Off the top of my head, I'd say put the addresses in a hash of arrays, with the hash keys being the classes, and the array size therefore being the number of addresses in that class. Then get a random member of the array for a random hash key, and delete that array member. If the array becomes empty, delete the hash key so you can't pick that one any more. Repeat until there are no hash keys left in the hash. There might be more-efficient ways to do that, but that's where I'd start. UPDATE: I've got an idea on this; should have a code snippet for you later this evening!
D Ruth Bavousett
In Section
Seekers of Perl Wisdom
|
|