in reply to Helping with sorting
Except that, as noted elsewhere, you are strangely doing a descending numerical sort with an ascending alphabetic sort. So we need to flip around one of those sorts. Easy enough, if you don't mind limiting your numeric range a little bit:my @sorted = sort { sprintf("%010d%s",$a,$a) cmp sprintf("%010d%s",$b, +$b) } @array;
or, better but still quite Wrong:my @sorted = sort { sprintf("%08d%s",99999999-$a,$a) cmp sprintf("%08d +%s",99999999-$b,$b) } @array;
my @sorted = sort { sprintf("%010u%s",-$a,$a) cmp sprintf("%010u%s",-$ +b,$b) } @array;
|
|---|