in reply to Re: Data::Sorting
in thread Data::Sorting

And if you have a lot of data and you want the sorting to be fast, you can use:

my @sortedKeys= map { ( split /\0/, $_ )[-1] } sort map { join "\0", @{$hash{$_}}[0,1,2], $_ } keys %hash;

assuming no "\0" characters in your keys and values (often a pretty safe bet).

- tye        

Updated to replace original line

map { join "\0", $hash{$_}[0,1,2], $_ }

with corrected line. Thanks, BrowserUk.

Replies are listed 'Best First'.
Re: Re^2: Data::Sorting (fast)
by BrowserUk (Patriarch) on May 27, 2004 at 18:16 UTC

    Don't you need to dereference the hash value to get the array slice to work?

    map { join "\0", @{ $hash{$_} }[0,1,2], $_ }

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail