File Coverage

blib/lib/Sort/Sub/asciibetically.pm
Criterion Covered Total %
statement 18 21 85.7
branch 6 8 75.0
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 30 38 78.9


line stmt bran cond sub pod time code
1             package Sort::Sub::asciibetically;
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   16 use 5.010;
  1         3  
9 1     1   4 use strict;
  1         1  
  1         17  
10 1     1   4 use warnings;
  1         1  
  1         67  
11              
12             sub meta {
13             return {
14 0     0 0 0 v => 1,
15             summary => 'Sort ascibetically (string-wise)',
16             };
17             }
18              
19             sub gen_sorter {
20 3     3 0 6 my ($is_reverse, $is_ci) = @_;
21              
22             sub {
23 1     1   5 no strict 'refs';
  1         1  
  1         136  
24              
25 34     34   51 my $caller = caller();
26 34 50       47 my $a = @_ ? $_[0] : ${"$caller\::a"};
  0         0  
27 34 50       37 my $b = @_ ? $_[1] : ${"$caller\::b"};
  0         0  
28              
29 34 100       45 my $cmp = $is_ci ? lc($a) cmp lc($b) : $a cmp $b;
30 34 100       64 $is_reverse ? -1*$cmp : $cmp;
31 3         15 };
32             }
33              
34             1;
35             # ABSTRACT: Sort ascibetically (string-wise)
36              
37             __END__