Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 avoiding work at the Monastery: (9)
As of 2014-11-23 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (134 votes), past polls