Tie::Hash::Rank

A hash which turns values into ranking positions
Download

Tie::Hash::Rank Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Cantrell
  • Publisher web site:
  • http://search.cpan.org/~dcantrell/

Tie::Hash::Rank Tags


Tie::Hash::Rank Description

A hash which turns values into ranking positions Tie::Hash::Rank is a Perl module that allows you to tie a hash such that when you retrieve values from it, you get the value's rank instead of the actual data. By default, it ranks items numerically, with the highest value getting rank 1, and given two equal values they will also get the same rank.The following named parameters are supported:ALGORITHMUse ALGORITHM to sort items prior to ranking them. The default is a reverse-numeric sort. Specify it thus $DATA{$a} $DATA{$b} to do a normal numeric sort. Divining how to do other types of sort is left as a trivial exercise for the reader. See perldoc -f sort.EQUALITYSUFFIXAppend EQUALITYSUFFIX to the rank of items with equal rank. The default is to have no EQUALITYSUFFIX, but a common alternative would be an = sign.EQUALITYPREFIXPrepend EQUALITYPREFIX to the rank of items with equal rank. The default is to have no EQUALITYPREFIX, but a common alternative would be an = sign.RECALCULATECan be either onstore or onfetch, and defaults to 'onstore'. This determines when the module recalculates the ranks. 'onstore' makes it recalculate whenever you add a value to the hash, and 'onfetch' whenever you retrieve a value. Use this option if you need to tune your hash for data which is mainly read or mainly written, although it will make very little difference for small data-sets.SYNOPSIS use Tie::Hash::Rank tie my %ranks, 'Tie::Hash::Rank'; %ranks=( Adams => 78, Davies => 35, Edwards => 84, Thomas => 47 ); print $ranks{Adams}; Requirements: · Perl


Tie::Hash::Rank Related Software