Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: I need to sort out some values and get only the highest generated by my perl script

by riffraff (Pilgrim)
on Oct 29, 2004 at 15:29 UTC ( [id://403789]=note: print w/replies, xml ) Need Help??


in reply to Re: I need to sort out some values and get only the highest generated by my perl script
in thread I need to sort out some values and get only the highest generated by my perl script

If all he is doing is printing the largest value, would not the following suffice?

program.pl|sort -n|tail -1

No extra coding needed, and it uses programs that already exist on the system.

  • Comment on Re^2: I need to sort out some values and get only the highest generated by my perl script
  • Download Code

Replies are listed 'Best First'.
Re^3: I need to sort out some values and get only the highest generated by my perl script
by Eimi Metamorphoumai (Deacon) on Oct 29, 2004 at 15:52 UTC
    If that's what's happening, yes. I read his message as "I have a loop that goes 1000 times, and each time it generates a bunch of data. I want the largest value produced from each run of the loop, ie, 1000 largest values," which wouldn't work from your model. Also, it's almost certain to be less efficient (O(n log n) instead of O(n) to do the sort, then throw away all the extra sort data that was just computed).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found