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



--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to