in reply to Re: Re: Slow at sorting?
in thread Slow at sorting?

How about extending it to something like

pack("n N n", $1, $2, $3).$4

thereby we would sort CD# > 9 correctly, decrease the memory footprint and allow for the fast intrinsic ASCIIbetical sort.
Perhaps even to the point where fast hash lookups can be used.

It's a pity the data is in practice unavailable

Here's what I would like to time ...

. . my (%sort_hash); my $offset = 0; while (<IN>) { if( m/^CD(\d+)\\(\d+)\.pdf\((\d+)\)\s-\s\[(.+?)\]/ ) { $sort_hash{pack("n N n", $1, $2, $3).$4} = $offset; } $offset = tell(IN); } foreach my $k (sort keys %sort_hash) { seek IN, $sort_hash{$k}, 0; print OUT scalar(<IN>); }

Replies are listed 'Best First'.
Re: Re: Slow at sorting?
by petral (Curate) on Nov 22, 2001 at 03:56 UTC
    And then, why not pack the offset on the end, and unpack substr -4 when you're done. Then you're down to a simple array sort and the only problem is the original one: sooner or later you scale up till you're paging forever.

      p
      True, but I'm not certain that the hash is slower only that it requires more memory, however that has to be tested, IMHO.