File Coverage

blib/lib/Sort/Sub/record_by_order.pm
Criterion Covered Total %
statement 18 21 85.7
branch 4 6 66.6
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 28 36 77.7


line stmt bran cond sub pod time code
1             package Sort::Sub::record_by_order;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-02-28'; # DATE
5             our $DIST = 'Sort-Sub'; # DIST
6             our $VERSION = '0.118'; # VERSION
7              
8 1     1   21 use 5.010001;
  1         4  
9 1     1   5 use strict;
  1         2  
  1         20  
10 1     1   5 use warnings;
  1         1  
  1         79  
11              
12             sub meta {
13             return {
14 0     0 0 0 v => 1,
15             compares_record => 1,
16             };
17             }
18              
19             sub gen_sorter {
20 3     3 0 8 my ($is_reverse, $is_ci) = @_;
21              
22             sub {
23 1     1   7 no strict 'refs';
  1         2  
  1         159  
24              
25 12     12   20 my $caller = caller();
26 12 50       22 my $a = @_ ? $_[0] : ${"$caller\::a"};
  0         0  
27 12 50       18 my $b = @_ ? $_[1] : ${"$caller\::b"};
  0         0  
28              
29 12         19 my $cmp = $a->[1] <=> $b->[1];
30 12 100       30 $is_reverse ? -1*$cmp : $cmp;
31 3         17 };
32             }
33              
34             1;
35             # ABSTRACT:
36              
37             __END__