in reply to sorting an array

Given the simple nature of the data, i.e. each element startswith 'ch', I'm surprised others didn't do this:
my @sorted = sort { substr($a,2) <=> substr($b,2) } @array;
OK, so it's calling substr rather a lot of times, so with a large array that might be slow. Alternatively we could cache it:
@array = map {substr($_,2)} @array; my @sorted = sort { $a <=> $b } @array; @sorted = map { "ch$_" } @sorted;