File Coverage

blib/lib/Sort/Sub/numerically.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::numerically;
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   20 use 5.010;
  1         3  
9 1     1   5 use strict;
  1         2  
  1         19  
10 1     1   5 use warnings;
  1         2  
  1         65  
11              
12             sub meta {
13             return {
14 0     0 0 0 v => 1,
15             summary => 'Sort numerically',
16             };
17             }
18              
19             sub gen_sorter {
20 3     3 0 7 my ($is_reverse, $is_ci) = @_;
21              
22             sub {
23 1     1   5 no strict 'refs';
  1         11  
  1         164  
24              
25 8     8   14 my $caller = caller();
26 8 50       16 my $a = @_ ? $_[0] : ${"$caller\::a"};
  0         0  
27 8 50       13 my $b = @_ ? $_[1] : ${"$caller\::b"};
  0         0  
28              
29 8         16 my $cmp = $a <=> $b;
30 8 100       26 $is_reverse ? -1*$cmp : $cmp;
31 3         17 };
32             }
33              
34             1;
35             # ABSTRACT: Sort numerically
36              
37             __END__