Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Lottery using arrays

by Anonymous Monk
on Sep 27, 2012 at 00:56 UTC ( #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], )


Comment on Re: Lottery using arrays
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2015-07-29 05:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls