Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: File Sorting Question

by jeroenes (Priest)
on Jun 19, 2001 at 02:00 UTC ( #89488=note: print w/ replies, xml ) Need Help??


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)


Comment on Re: File Sorting Question
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89488]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2014-12-25 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls