Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Help with sorting/randomizing?

by druthb (Beadle)
on Mar 25, 2012 at 19:42 UTC ( #961529=note: print w/replies, xml ) Need Help??


in reply to Help with sorting/randomizing?

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2020-11-29 16:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?