Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Answer: How do I write my own sorting routine?

( #21186=categorized answer: print w/ replies, xml ) Need Help??

Q&A > sorting > How do I write my own sorting routine? contributed by nardo

return -1 means $a goes before $b, return +1 means $b goes before $a, return 0 means they are equal.

The "spaceship operator", <=>, returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument.

Its stringwise counterpart, cmp, returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument.

To learn more about these operators, please read perlop.
To learn more about the sort function, please read perlfunc.

Comment on Answer: How do I write my own sorting routine?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-07-25 23:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls