File Coverage

blib/lib/Sort/Key.pm
Criterion Covered Total %
statement 35 37 94.5
branch 8 12 66.6
condition n/a
subroutine 7 8 87.5
pod 2 3 66.6
total 52 60 86.6


line stmt bran cond sub pod time code
1             package Sort::Key;
2              
3             our $VERSION = '1.33';
4              
5 5     5   139960 use 5.006;
  5         20  
  5         209  
6              
7 5     5   31 use strict;
  5         9  
  5         210  
8 5     5   27 use warnings;
  5         15  
  5         154  
9 5     5   26 use Carp;
  5         6  
  5         598  
10              
11 5     5   2839 use Sort::Key::Types;
  5         12  
  5         3025  
12              
13             require Exporter;
14              
15             our @ISA = qw(Exporter);
16             our @EXPORT_OK = qw( nsort nsort_inplace
17             isort isort_inplace
18             usort usort_inplace
19             rsort rsort_inplace
20             rnsort rnsort_inplace
21             risort risort_inplace
22             rusort rusort_inplace
23              
24             keysort keysort_inplace
25             rkeysort rkeysort_inplace
26             nkeysort nkeysort_inplace
27             rnkeysort rnkeysort_inplace
28             ikeysort ikeysort_inplace
29             rikeysort rikeysort_inplace
30             ukeysort ukeysort_inplace
31             rukeysort rukeysort_inplace
32              
33             multikeysorter multikeysorter_inplace);
34              
35             require XSLoader;
36             XSLoader::load('Sort::Key', $VERSION);
37              
38             sub multikeysorter {
39 13 100   13 1 39 if (ref $_[0] eq 'CODE') {
40 6         10 my $keygen = shift;
41 6 50       19 @_ or croak "too few keys";
42 6         17 my $ptypes = Sort::Key::Types::combine_types(@_);
43 6         18 my $sub = Sort::Key::Types::combine_sub($keygen, undef, @_);
44 6         54 return _multikeysorter($ptypes, $sub, undef);
45             }
46             else {
47 7 50       19 @_ or croak "too few keys";
48 7         21 my $ptypes = Sort::Key::Types::combine_types(@_);
49 7         24 my $sub = Sort::Key::Types::combine_sub('@_', undef, @_);
50 7         72 return _multikeysorter($ptypes, undef, $sub)
51             }
52             }
53              
54             sub multikeysorter_inplace {
55 11 100   11 1 29 if (ref $_[0] eq 'CODE') {
56 6         10 my $keygen = shift;
57 6 50       17 @_ or croak "too few keys";
58 6         18 my $ptypes = Sort::Key::Types::combine_types(@_);
59 6         21 my $sub = Sort::Key::Types::combine_sub($keygen, undef, @_);
60 6         63 return _multikeysorter_inplace($ptypes, $sub, undef);
61             }
62             else {
63 5 50       15 @_ or croak "too few keys";
64 5         14 my $ptypes = Sort::Key::Types::combine_types(@_);
65 5         16 my $sub = Sort::Key::Types::combine_sub('@_', undef, @_);
66 5         38 return _multikeysorter_inplace($ptypes, undef, $sub);
67             }
68             }
69              
70             sub register_type {
71 0     0 0   warn "Warning, Sort::Key API changed: register_type function has been moved to module Sort::Key::Types";
72 0           goto &Sort::Key::Types::register_type;
73             }
74              
75              
76             1;
77              
78             __END__