| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sorter::from_sortkey; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
281762
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict 'subs', 'vars'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
5
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
442
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
8
|
|
|
|
|
|
|
our $DATE = '2024-01-24'; # DATE |
|
9
|
|
|
|
|
|
|
our $DIST = 'Sorter-from_sortkey'; # DIST |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
|
13
|
|
|
|
|
|
|
return +{ |
|
14
|
0
|
|
|
0
|
0
|
|
v => 1, |
|
15
|
|
|
|
|
|
|
args => { |
|
16
|
|
|
|
|
|
|
sortkey => {schema=>'perl::sortkey::modname_with_optional_args*', req=>1}, |
|
17
|
|
|
|
|
|
|
reverse => {schema => 'bool*'}, |
|
18
|
|
|
|
|
|
|
ci => {schema => 'bool*'}, |
|
19
|
|
|
|
|
|
|
}, |
|
20
|
|
|
|
|
|
|
}; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub gen_sorter { |
|
24
|
0
|
|
|
0
|
0
|
|
my %args = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
my $sortkey = $args{sortkey} or die "Please specify sortkey"; |
|
27
|
0
|
|
|
|
|
|
my $reverse = $args{reverse}; |
|
28
|
0
|
|
|
|
|
|
my $ci = $args{ci}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
require Module::Load::Util; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my ($mod, $args) = Module::Load::Util::_normalize_module_with_optional_args($sortkey); |
|
33
|
0
|
|
|
|
|
|
$mod = Module::Load::Util::_load_module({ns_prefix=>"SortKey"}, $mod); |
|
34
|
0
|
0
|
|
|
|
|
my $is_num = $mod =~ /\ASortKey::Num::/ ? 1:0; |
|
35
|
0
|
|
|
|
|
|
my $keygen = &{"$mod\::gen_keygen"}(@$args); |
|
|
0
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub { |
|
38
|
|
|
|
|
|
|
my @records = map { |
|
39
|
0
|
0
|
|
0
|
|
|
my $key = $args{ci} ? lc($keygen->($_)) : $keygen->($_); |
|
|
0
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
[$_, $key]; |
|
41
|
|
|
|
|
|
|
} @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
map { $_->[0] } sort { ($is_num ? ($a->[1] <=> $b->[1]) : ($a->[1] cmp $b->[1])) * ($reverse ? -1:1) } @records; |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
# ABSTRACT: Sort by keys generated by a SortKey:: module |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |