line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sort::Sub::by_several; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2019-12-17'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Sort-Sub-by_several'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1658
|
use 5.010001; |
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
220
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub meta { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
0
|
0
|
v => 1, |
15
|
|
|
|
|
|
|
summary => 'Sort by one or more sorters', |
16
|
|
|
|
|
|
|
args => { |
17
|
|
|
|
|
|
|
first => {schema=>'sortsub::spec*', req=>1, pos=>0}, |
18
|
|
|
|
|
|
|
second => {schema=>'sortsub::spec*', req=>0, pos=>1}, |
19
|
|
|
|
|
|
|
third => {schema=>'sortsub::spec*', req=>0, pos=>2}, |
20
|
|
|
|
|
|
|
fourth => {schema=>'sortsub::spec*', req=>0, pos=>3}, |
21
|
|
|
|
|
|
|
fifth => {schema=>'sortsub::spec*', req=>0, pos=>4}, |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
args_rels => { |
24
|
|
|
|
|
|
|
'dep_any&' => [ |
25
|
|
|
|
|
|
|
[second => ['first']], |
26
|
|
|
|
|
|
|
[third => ['second']], |
27
|
|
|
|
|
|
|
[fourth => ['third']], |
28
|
|
|
|
|
|
|
[fifth => ['fourth']], |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub gen_sorter { |
35
|
4
|
|
|
4
|
0
|
4596
|
require Sort::Sub; |
36
|
4
|
|
|
|
|
9
|
my ($is_reverse, $is_ci, $args) = @_; |
37
|
|
|
|
|
|
|
|
38
|
4
|
50
|
|
|
|
21
|
my $sorter1 = defined $args->{first} ? Sort::Sub::get_sorter($args->{first} ) : undef; |
39
|
4
|
50
|
|
|
|
949
|
my $sorter2 = defined $args->{second} ? Sort::Sub::get_sorter($args->{second}) : undef; |
40
|
4
|
50
|
|
|
|
883
|
my $sorter3 = defined $args->{third} ? Sort::Sub::get_sorter($args->{third} ) : undef; |
41
|
4
|
50
|
|
|
|
9
|
my $sorter4 = defined $args->{fourth} ? Sort::Sub::get_sorter($args->{fourth}) : undef; |
42
|
4
|
50
|
|
|
|
7
|
my $sorter5 = defined $args->{fifth} ? Sort::Sub::get_sorter($args->{fifth} ) : undef; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub { |
45
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
230
|
|
46
|
|
|
|
|
|
|
|
47
|
92
|
|
|
92
|
|
518
|
my $caller = caller(); |
48
|
92
|
50
|
|
|
|
144
|
my $a = @_ ? $_[0] : ${"$caller\::a"}; |
|
92
|
|
|
|
|
186
|
|
49
|
92
|
50
|
|
|
|
134
|
my $b = @_ ? $_[1] : ${"$caller\::b"}; |
|
92
|
|
|
|
|
172
|
|
50
|
|
|
|
|
|
|
|
51
|
92
|
|
|
|
|
116
|
my $cmp; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
54
|
92
|
100
|
|
|
|
115
|
$cmp = $sorter1->($a, $b); last if $cmp; last unless $sorter2; |
|
92
|
50
|
|
|
|
152
|
|
|
92
|
|
|
|
|
753
|
|
|
46
|
|
|
|
|
78
|
|
55
|
46
|
50
|
|
|
|
77
|
$cmp = $sorter2->($a, $b); last if $cmp; last unless $sorter3; |
|
46
|
0
|
|
|
|
385
|
|
|
0
|
|
|
|
|
0
|
|
56
|
0
|
0
|
|
|
|
0
|
$cmp = $sorter3->($a, $b); last if $cmp; last unless $sorter4; |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
57
|
0
|
0
|
|
|
|
0
|
$cmp = $sorter4->($a, $b); last if $cmp; last unless $sorter5; |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
$cmp = $sorter5->($a, $b); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
92
|
100
|
|
|
|
203
|
$is_reverse ? -1*$cmp : $cmp; |
62
|
4
|
|
|
|
|
17
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
# ABSTRACT: Sort by one or more sorters |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |