Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: beginner - ordering tuples

by BrowserUk (Patriarch)
on Nov 13, 2010 at 14:24 UTC ( [id://871234]=note: print w/replies, xml ) Need Help??


in reply to Re^4: beginner - ordering tuples
in thread beginner - ordering tuples

why has it put some of the output in single quotes:

The input array is initialised with strings. Left unmodified, all the values would be output in quotes.

During the sort process, any values that are compared as numbers using <=>, will first be converted, internally, to their (binary) numeric representation.

But as the first & last pairs in your example have unique first elements (1 & 12), there is never any need to compare their second elements, hence they are never converted to numeric representation, and so are output as strings.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
+

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found