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

Re: Sort Array

by ZZamboni (Curate)
on Jun 08, 2001 at 02:02 UTC ( #86777=note: print w/ replies, xml ) Need Help??


in reply to Sort Array

By default sort uses the cmp operator to compare elements, which does a string comparison. In ASCII order, "10" comes before "8", which is why you are getting those results. As wog pointed out, you have to instruct the <=> operator to make it compare things as numbers.

--ZZamboni


Comment on Re: Sort Array

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-07-05 21:57 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 (68 votes), past polls