Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Lottery using arrays

by Anonymous Monk
on Sep 27, 2012 at 00:56 UTC ( [id://995892]=note: print w/replies, xml ) Need Help??


in reply to Lottery using arrays

See sort it has lots of examples , also Tutorials: List Processing, Filtering, and Sorting and perldoc -q sort

#!/usr/bin/perl -- use Data::Dump; @num = @freq = 0..9; dd\@freq,\@num; { my @oldnum=@num; @num = sort { $freq[$b]<=> $freq[$a] } @num; @freq[@oldnum] = @freq[@num]; dd\@freq,\@num; } __END__ ([0 .. 9], [0 .. 9]) ( [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], )

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-29 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found