Keep It Simple, Stupid | |
PerlMonks |
Re: Sorting Outline Numbersby spiritway (Vicar) |
on Aug 11, 2005 at 01:23 UTC ( [id://482821]=note: print w/replies, xml ) | Need Help?? |
How about converting those strings into ones in which leading zeroes are included, sort the strings, and then convert the strings back to the numerals as shown? The following code is painful to see for Perl programmers. Forgive me. I don't yet speak Perlish very well.
The output is:
A similar use of sprintf could be used to convert the numbers with leading zeroes back to ones that do not have leading zeroes. I leave this as an exercise for the reader, and to spare you gentle folks any more of my ugly code.
In Section
Seekers of Perl Wisdom
|
|