Welcome to the Monastery | |
PerlMonks |
(tye)Re2: Sorting by_numberby tye (Sage) |
on Sep 15, 2001 at 22:24 UTC ( [id://112643]=note: print w/replies, xml ) | Need Help?? |
Yes, for more robust versions of this, see the previously mentioned link. Actually, dealing with non-negative integers beyond 2**32 or even that won't fit in a double (either accurately or at all) is rather easy. For example, ignoring the case of extra leading zeros again: This deals with any sequence of nearly 2**31 digits (I won't commit beyond that because I'm not certain that all ports of Perl will have a length function that works beyond that -- not that even 2**31 is much of a practical limitation). Note that it preserves leading zeros unlike the previous one-liner, but it doesn't sort them intuitively. To deal with extra leading zeros properly requires a bit more work, for example:
Also note that I intentionally did not use a Schwartzian Transform as it is rather slower and uses more memory. - tye (but my friends call me "Tye")
In Section
Craft
|
|