This file is indexed.

/usr/lib/x86_64-linux-gnu/perl5/5.22/Sort/Key/Top.pm is in libsort-key-top-perl 0.08-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
package Sort::Key::Top;

our $VERSION = '0.08';

use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT_OK = qw( top
                     ltop
                     ntop
                     itop
                     utop
                     rtop
                     rltop
                     rntop
                     ritop
                     rutop
                     keytop
                     lkeytop
                     nkeytop
                     ikeytop
                     ukeytop
                     rkeytop
                     rlkeytop
                     rnkeytop
                     rikeytop
                     rukeytop
                     part
                     lpart
                     npart
                     ipart
                     upart
                     rpart
                     rlpart
                     rnpart
                     ripart
                     rupart
                     keypart
                     lkeypart
                     nkeypart
                     ikeypart
                     ukeypart
                     rkeypart
                     rlkeypart
                     rnkeypart
                     rikeypart
                     rukeypart
                     partref
                     lpartref
                     npartref
                     ipartref
                     upartref
                     rpartref
                     rlpartref
                     rnpartref
                     ripartref
                     rupartref
                     keypartref
                     lkeypartref
                     nkeypartref
                     ikeypartref
                     ukeypartref
                     rkeypartref
                     rlkeypartref
                     rnkeypartref
                     rikeypartref
                     rukeypartref
                     topsort
                     ltopsort
                     ntopsort
                     itopsort
                     utopsort
                     rtopsort
                     rltopsort
                     rntopsort
                     ritopsort
                     rutopsort
                     keytopsort
                     lkeytopsort
                     nkeytopsort
                     ikeytopsort
                     ukeytopsort
                     rkeytopsort
                     rlkeytopsort
                     rnkeytopsort
                     rikeytopsort
                     rukeytopsort
                     atpos
                     latpos
                     natpos
                     iatpos
                     uatpos
                     ratpos
                     rlatpos
                     rnatpos
                     riatpos
                     ruatpos
                     keyatpos
                     lkeyatpos
                     nkeyatpos
                     ikeyatpos
                     ukeyatpos
                     rkeyatpos
                     rlkeyatpos
                     rnkeyatpos
                     rikeyatpos
                     rukeyatpos
                     head
                     lhead
                     nhead
                     ihead
                     uhead
                     rhead
                     rlhead
                     rnhead
                     rihead
                     ruhead
                     keyhead
                     lkeyhead
                     nkeyhead
                     ikeyhead
                     ukeyhead
                     rkeyhead
                     rlkeyhead
                     rnkeyhead
                     rikeyhead
                     rukeyhead
                     tail
                     ltail
                     ntail
                     itail
                     utail
                     rtail
                     rltail
                     rntail
                     ritail
                     rutail
                     keytail
                     lkeytail
                     nkeytail
                     ikeytail
                     ukeytail
                     rkeytail
                     rlkeytail
                     rnkeytail
                     rikeytail
                     rukeytail
 );

for ((@EXPORT_OK)) {
    my $slot = $_;
    $slot =~ s/key/slot/ and
        push @EXPORT_OK, $slot;
}

require XSLoader;
XSLoader::load('Sort::Key::Top', $VERSION);

1;
__END__

=head1 NAME

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

=head1 SYNOPSIS

  use Sort::Key::Top (nkeytop top);

  # select 5 first numbers by absolute value:
  @top = nkeytop { abs $_ } 5 => 1, 2, 7, 5, 5, 1, 78, 0, -2, -8, 2;
         # ==> @top = (1, 2, 1, 0, -2)

  # select 5 first numbers by absolute value and sort accordingly:
  @top = nkeytopsort { abs $_ } 5 => 1, 2, 7, 5, 5, 1, 78, 0, -2, -8, 2;
         # ==> @top = (0, 1, 1, 2, -2)

  # select 5 first words by lexicographic order:
  @a = qw(cat fish bird leon penguin horse rat elephant squirrel dog);
  @top = top 5 => @a;
         # ==> @top = qw(cat fish bird elephant dog);

=head1 DESCRIPTION

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 C<@data> using the expression inside the block. Then it
selects and orders the C<$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 C<$n> elements from the bottom are selected:

  topsort 3 => qw(foo doom me bar doz hello);
       # ==> ('bar', 'doz', 'doom')

  topsort -3 => qw(foo doom me bar doz hello);
       # ==> ('foo', 'hello', 'me')

  top 3 => qw(foo doom me bar doz hello);
       # ==> ('doom', 'bar', 'doz')

  top -3 => qw(foo doom me bar doz hello);
       # ==> ('foo', 'me', '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:

  # n = 5;
  scalar(topsort 5 => @data) eq (sort @data)[4]    # true

  # n = -5;
  scalar(topsort -5 => @data) eq (sort @data)[-5]  # true

Note that on scalar context, the C<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 C<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);
     # ==> a aa aac ab b

=item - use an array or hash index instead of a subroutine to extract
the key

  slottop 0, 2, [4], [1], [3], [2], [4];
     # ==> [1], [2]

=item - return the selected values in the original order

  top 5 => qw(a b ab t uu g h aa aac);
     # ==> a b ab 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);
     # ==> ab aa aac

  rnkeytopsort { length $_ } 3 => qw(a ab aa aac b t uu g h);
     # ==> aac ab aa

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

=back

=item - select the head element from the list sorted

  nhead 6, 7, 3, 8, 9, 9;
      # ==> 3

  nkeyhead { length $_ } qw(a ab aa aac b t uu uiyii)
      # ==> 'a'

=item - select the tail element from the list sorted

  tail qw(a ab aa aac b t uu uiyii);
      # ==> 'uu'

  nkeytail { length $_ } qw(a ab aa aac b t uu uiyii)
      # ==> 'uiyii'

=item - select the element at position n from the list sorted

  atpos 3, qw(a ab aa aac b t uu uiyii);
      # ==> 'ab';

  rnkeyatpos { abs $_ } 2 => -0.3, 1.1, 4, 0.1, 0.9, -2;
      # ==> 1.1

  rnkeyatpos { abs $_ } -2 => -0.3, 1.1, 4, 0.1, 0.9, -2;
      # ==> -0.3

Note that for the C<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);
      # ==> a cc g bbbb ddddd 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);
      # ==> [a cc g] [bbbb ddddd fd]

=back


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
  ruatpos

  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
  rupart

  keypart lkeypart nkeypart ikeypart ukeypart rkeypart
  rlkeypart rnkeypart rikeypart rukeypart

  slotpart lslotpart nslotpart islotpart uslotpart rslotpart
  rlslotpart rnslotpart rislotpart ruslotpart


=head1 SEE ALSO

L<Sort::Key>, L<perlfunc/sort>.

L<Sort::Key::Top::PP> by Toby Inkster, provides a subset of the API of
Sort::Key::Top and is written in pure Perl.

The Wikipedia article about selection algorithms
L<http://en.wikipedia.org/wiki/Selection_algorithm>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2006-2008, 2011, 2012, 2014 by Salvador FandiE<ntilde>o
(sfandino@yahoo.com).

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.

=cut