http://www.perlmonks.org?node_id=89488


in reply to File Sorting Question

Any solution is going to be expensive.
  1. Don't eat memory:
    my $ignore = '(^The )|(^A )'; ... @sorted = sort { $a =~ s/$ignore//; $b =~ s/$ignore//; lc( $a ) cmp lc( $b ); } @indata;
  2. Or store better keys first:
    %data = map { my $data = $_; s/$ignore//; ($_, $data } @indata; @sorted = @data{ sort{ lc( $a) cmp lc( $b)} keys %data };

Hope this helps,

Jeroen
"We are not alone"(FZ)