FAQ

On 2014-03-26 12:36, shawn wilson wrote:

return
sort {
return $pre->{$a} <=> $pre->{$b}
if $pre->{$a} && $pre->{$b};
return -1 if $pre->{$a};
return +1 if $pre->{$b};
return $a cmp $b;
} @$data;
}
Benchmark-alternative:

    sort {
        $pre->{$a}
        ? $pre->{$b}
          ? $pre->{$a} <=> $pre->{$b}
          : -1
        : $pre->{$b}
          ? +1
          : $a cmp $b;
    } @$data;


If most words are not in $pre, then reverse the tests.

--
Ruud

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 9 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedMar 25, '14 at 1:55p
activeMar 26, '14 at 12:40p
posts9
users7
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase