perl-Sort-Key-Top - select and sort top n elements

Property Value
Distribution ALT Linux Sisyphus
Repository Autoimports x86_64
Package filename perl-Sort-Key-Top-0.08-alt4.1.x86_64.rpm
Package name perl-Sort-Key-Top
Package version 0.08
Package release alt4.1
Package architecture x86_64
Package type rpm
Category Development/Perl
Homepage -
License -
Maintainer -
Download size 55.16 KB
Installed size 55.16 KB
The functions available from this module select the top n elements from a list
using several common orderings and custom key extraction procedures.
They are all variations around
keytopsort { CALC_KEY($_) } $n => @data;
In array context, this function calculates the ordering key for every
element in `@data' using the expression inside the block. Then it
selects and orders the `$n' elements with the lower keys when
compared lexicographically.
It is equivalent to the pure Perl expression:
(sort { CALC_KEY($a) cmp CALC_KEY($b) } @data)[0 .. $n-1];
If $n is negative, the last `$n' elements from the bottom are selected:
topsort 3 => qw(foo doom me bar doz hello);
topsort -3 => qw(foo doom me bar doz hello);
top 3 => qw(foo doom me bar doz hello);
top -3 => qw(foo doom me bar doz hello);
In scalar context, the value returned by the functions on this module
is the cutoff value allowing to select nth element from the
array. For instance:
scalar(topsort 5 => @data) eq (sort @data)[4]    # true
scalar(topsort -5 => @data) eq (sort @data)[-5]  # true
Note that on scalar context, the `sort' variations (see below) are
usually the right choice:
scalar topsort 3 => qw(me foo doz doom me bar hello); # ==> 'doz'
scalar top 3 => qw(me foo doz doom me bar hello); # ==> 'bar'
Note also, that the index is 1-based (it starts at one instead of at
zero). The `atpos' set of functions explained below do the same and
are 0-based.
Variations allow to:
=over 4
=item - use the own values as the ordering keys
topsort 5 => qw(a b ab t uu g h aa aac);
=item - use an array or hash index instead of a subroutine to extract
the key
slottop 0, 2, [4], [1], [3], [2], [4];
=item - return the selected values in the original order
top 5 => qw(a b ab t uu g h aa aac);
=item - use a different ordering
For instance comparing the keys as numbers, using the locale
configuration or in reverse order:
rnkeytop { length $_ } 3 => qw(a ab aa aac b t uu g h);
rnkeytopsort { length $_ } 3 => qw(a ab aa aac b t uu g h);
A prefix is used to indicate the required ordering:
=over 4
=item (no prefix)
lexicographical ascending order
=item r
lexicographical descending order
=item l
lexicographical ascending order obeying locale configuration
=item r
lexicographical descending order obeying locale configuration
=item n
numerical ascending order
=item rn
numerical descending order
=item i
numerical ascending order but converting the keys to integers first
=item ri
numerical descending order but converting the keys to integers first
=item u
numerical ascending order but converting the keys to unsigned integers first
=item ru
numerical descending order but converting the keys to unsigned integers first
=item - select the head element from the list sorted
nhead 6, 7, 3, 8, 9, 9;
nkeyhead { length $_ } qw(a ab aa aac b t uu uiyii)
=item - select the tail element from the list sorted
tail qw(a ab aa aac b t uu uiyii);
nkeytail { length $_ } qw(a ab aa aac b t uu uiyii)
=item - select the element at position n from the list sorted
atpos 3, qw(a ab aa aac b t uu uiyii);
rnkeyatpos { abs $_ } 2 => -0.3, 1.1, 4, 0.1, 0.9, -2;
rnkeyatpos { abs $_ } -2 => -0.3, 1.1, 4, 0.1, 0.9, -2;
Note that for the `atpos' set of functions indexes start at zero.
=item - return a list composed by the elements with the first n
ordered keys and then the remaining ones.
ikeypart { length $_ } 3 => qw(a bbbb cc ddddd g fd);
=item - return two arrays references, the first array containing the
elements with the first n ordered keys and the second with the rest.
keypartref { length $_ } 3 => qw(a bbbb cc ddddd g fd);
The full list of available functions is:
top ltop ntop itop utop rtop rltop rntop ritop rutop
keytop lkeytop nkeytop ikeytop ukeytop rkeytop rlkeytop rnkeytop
rikeytop rukeytop
slottop lslottop nslottop islottop uslottop rslottop rlslottop rnslottop
rislottop ruslottop
topsort ltopsort ntopsort itopsort utopsort rtopsort rltopsort
rntopsort ritopsort rutopsort
keytopsort lkeytopsort nkeytopsort ikeytopsort ukeytopsort
rkeytopsort rlkeytopsort rnkeytopsort rikeytopsort rukeytopsort
slottopsort lslottopsort nslottopsort islottopsort uslottopsort
rslottopsort rlslottopsort rnslottopsort rislottopsort ruslottopsort
head lhead nhead ihead uhead rhead rlhead rnhead rihead ruhead
keyhead lkeyhead nkeyhead ikeyhead ukeyhead rkeyhead rlkeyhead
rnkeyhead rikeyhead rukeyhead
slothead lslothead nslothead islothead uslothead rslothead rlslothead
rnslothead rislothead ruslothead
tail ltail ntail itail utail rtail rltail rntail ritail rutail
keytail lkeytail nkeytail ikeytail ukeytail rkeytail rlkeytail
rnkeytail rikeytail rukeytail
slottail lslottail nslottail islottail uslottail rslottail rlslottail
rnslottail rislottail ruslottail
atpos latpos natpos iatpos uatpos ratpos rlatpos rnatpos riatpos
keyatpos lkeyatpos nkeyatpos ikeyatpos ukeyatpos rkeyatpos
rlkeyatpos rnkeyatpos rikeyatpos rukeyatpos
slotatpos lslotatpos nslotatpos islotatpos uslotatpos rslotatpos
rlslotatpos rnslotatpos rislotatpos ruslotatpos
part lpart npart ipart upart rpart rlpart rnpart ripart
keypart lkeypart nkeypart ikeypart ukeypart rkeypart
rlkeypart rnkeypart rikeypart rukeypart
slotpart lslotpart nslotpart islotpart uslotpart rslotpart
rlslotpart rnslotpart rislotpart ruslotpart


Package Version Architecture Repository
perl-Sort-Key-Top-0.08-alt4.1.i586.rpm 0.08 i586 Autoimports
perl-Sort-Key-Top - - -


Name Value
/usr/lib64/perl5 - - - -
perl( -
rpmlib(PayloadIsLzma) -
rpmlib(SetVersions) -
rtld(GNU_HASH) -


Name Value
perl(Sort/Key/ = 0.080
perl-Sort-Key-Top = 0.08-alt4.1


Type URL
Binary Package perl-Sort-Key-Top-0.08-alt4.1.x86_64.rpm
Source Package perl-Sort-Key-Top-0.08-alt4.1.src.rpm

Install Howto

  1. Add the following line to /etc/apt/sources.list:
    rpm [Sisyphus] x86_64 autoimports
    rpm [Sisyphus] noarch autoimports
  2. Update the package index:
    # sudo apt-get update
  3. Install perl-Sort-Key-Top rpm package:
    # sudo apt-get install perl-Sort-Key-Top



See Also

Package Description
perl-Sort-Naturally-ICU-0.7.8-alt3.x86_64.rpm Perl extension for human-friendly ("natural") sort order
perl-Sort-Naturally-XS-0.7.9-alt1.1.x86_64.rpm Perl extension for human-friendly ("natural") sort order
perl-Sort-Packed-0.08-alt4.1.x86_64.rpm perl module Sort-Packed
perl-Sort-XS-0.30-alt4.1.x86_64.rpm a ( very ) fast XS sort alternative for one dimension list
perl-Sourcecode-Spellchecker-0.03-alt4.1.x86_64.rpm Detects common misspellings in source code and suggests corrections
perl-Speech-eSpeak-0.4-alt4.1.x86_64.rpm Perl extension for eSpeak text to speech
perl-StackTrace-HiPerf-0.01-alt4.1.x86_64.rpm High performance stacktraces
perl-Starlink-AST-1.02-alt4.1.x86_64.rpm Interface to the Starlink AST library
perl-Statistics-CountAverage-XS-0.01-alt4.1.x86_64.rpm XS implementation of Statistics::CountAverage
perl-Statistics-EfficiencyCI-0.07-alt4.1.x86_64.rpm Robust confidence intervals on efficiencies
perl-Statistics-Lmoments-0.04-alt1.1.x86_64.rpm moments
perl-Stlgen-0.012-alt4.1.x86_64.rpm Create "Standard Template Library" (STL) C++ type containers but generate code in other languages
perl-Storable-AMF-1.23-alt3.1.x86_64.rpm serializing/deserializing AMF0/AMF3 data
perl-Store-Opaque-0.03-alt4.1.x86_64.rpm Opaque objects to prevent accidental Dumping or appearance in stack traces
perl-String-Base-0.003-alt4_7.x86_64.rpm String index offsetting