ALSO SEE: PerlGrepExactMatch

Here's a way to sort a list of textual entries, avoiding sorting on things like "the" and "a". It's not the most efficient code in the world (comments welcome!), but it works. I use it to sort album and artist names when building the lists in CooferCatMusic.

sub text_sort

 {<br />
        my $x=$a;<br />
        my $y=$b;5





$x cmp $y;



 {<br />
        my @list=('The Killers', 'Kenicke', 'Konstruction');13

@list=sort text_sort @list;


Similarly, if you want to do a genuine numeric sort (and not the usual alphanumeric sort), this might do the job for you (again, not necessarily the most efficient, but it works):

sub numeric_sort

 {<br />
        my $x=$a;<br />
        my $y=$b;19


        $y=~s/\D+.*$//g;<br />
        $x=$x+0;<br />

$x <=> $y;


There are better ways to do both of these things, but they might be a good start if you're looking for this sort of thing. By all means tell us your super-smart ways of doing the same thing ;-)