XP is just a number | |
PerlMonks |
Re: Changing Perl's sort Defaultby Ovid (Cardinal) |
on Oct 23, 2002 at 03:32 UTC ( [id://207282]=note: print w/replies, xml ) | Need Help?? |
If your read perldoc -f sort, you should learn all that you need to know. If you have 5.8 (?) or later, you can also read about the sort pragma with perldoc sort. I'm not sure how you are defining an alphanumeric sort (do you want digits before or after alphas?), so for the purpose of simplicity, I'll assume that you want a case-insensitive sort so that you don't have to worry worry about 'a' coming after 'Z'. To do this, you provide a sort subroutine. There are various ways to do this.
Some people prefer not to use an anonymous subroutine, so you have the option of naming it.
Again, read through the docs for more information on this. As a small side note, be aware that providing a block or subroutine to the sort function will automatically slow down its performance as is will no longer be relying on straight C code to perform the sort. Naturally, I rarely feel it's necessary to consider this issue, but it's nice to know. Cheers, Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In Section
Seekers of Perl Wisdom
|
|