Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Why didn't this sort?

by stephen (Priest)
on Jul 15, 2002 at 23:19 UTC ( #181965=note: print w/ replies, xml ) Need Help??


in reply to Why didn't this sort?

sort doesn't sort a list in-place. Instead, it returns a new sorted list. So:

foreach (sort @$outputRef) { print $_, "\n"; }
would print out a sorted list, but printing the contents of $outputRef would still print out an unsorted list.

If you need to save the sorted list for some reason, use an assignment:

@sorted = sort @$outputRef;

stephen

Note: Code untested, my Perlboxen are still in pieces...


Comment on Re: Why didn't this sort?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2015-07-31 18:27 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 (280 votes), past polls