Perl: the Markov chain saw | |
PerlMonks |
Re: Numeric sorting WITHOUT <=>by Marshall (Canon) |
on Oct 10, 2012 at 03:41 UTC ( [id://998124]=note: print w/replies, xml ) | Need Help?? |
If you want to sort by a numeric value, using the "spaceship" operator "<=>" is THE way to go! If you sort by "ascii order" on a numeric field, then you have to have the same number of "ascii digits" or the sort will not work. Use <=> to compare numeric values. Use cmp to compare string values.
I often advocate date/time strings like this:
2010-10-03 0837
In Section
Seekers of Perl Wisdom
|
|