Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://961529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (9)
As of 2024-03-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found