Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89488]
help
Chatterbox?
[choroba]: LanX they made a sequel, it's unimaginably terrible
[choroba]: Saxana and the Spell Lexicon
[Discipulus]: sometime a dream a movie: me in south of usa taking a tea with zentara and tybalt89..
[LanX]: Sequel? OO
LanX thinks it's more profitable to sue J.K. Rowling ... ;-)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2018-04-20 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?