line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sort::Sub::last_num_in_text; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-12-16'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1535
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub gen_sorter { |
11
|
1
|
|
|
1
|
0
|
14
|
my ($is_reverse, $is_ci) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub { |
14
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
260
|
|
15
|
|
|
|
|
|
|
|
16
|
9
|
|
|
9
|
|
47
|
my $caller = caller(); |
17
|
9
|
50
|
|
|
|
12
|
my $a = @_ ? $_[0] : ${"$caller\::a"}; |
|
9
|
|
|
|
|
16
|
|
18
|
9
|
50
|
|
|
|
11
|
my $b = @_ ? $_[1] : ${"$caller\::b"}; |
|
9
|
|
|
|
|
10
|
|
19
|
|
|
|
|
|
|
|
20
|
9
|
|
|
|
|
7
|
my $cmp; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @nums; |
23
|
0
|
100
|
|
|
|
0
|
my $num_a; @nums = $a =~ /(\d+)/g; $num_a = $nums[-1] if @nums; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
19
|
|
24
|
9
|
100
|
|
|
|
8
|
my $num_b; @nums = $b =~ /(\d+)/g; $num_b = $nums[-1] if @nums; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
16
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
27
|
9
|
100
|
100
|
|
|
7
|
if (defined $num_a && defined $num_b) { |
|
9
|
100
|
66
|
|
|
44
|
|
|
|
50
|
33
|
|
|
|
|
28
|
6
|
|
|
|
|
8
|
$cmp = $num_a <=> $num_b; |
29
|
6
|
50
|
|
|
|
10
|
last if $cmp; |
30
|
|
|
|
|
|
|
} elsif (defined $num_a && !defined $num_b) { |
31
|
1
|
|
|
|
|
1
|
$cmp = -1; |
32
|
1
|
|
|
|
|
2
|
last; |
33
|
|
|
|
|
|
|
} elsif (!defined $num_a && defined $num_b) { |
34
|
2
|
|
|
|
|
3
|
$cmp = 1; |
35
|
2
|
|
|
|
|
2
|
last; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
0
|
if ($is_ci) { |
39
|
0
|
|
|
|
|
0
|
$cmp = lc($a) cmp lc($b); |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
$cmp = $a cmp $b; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
9
|
50
|
|
|
|
23
|
$is_reverse ? -1*$cmp : $cmp; |
46
|
1
|
|
|
|
|
6
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
# ABSTRACT: Sort by last number found in text or (if no number is found) ascibetically |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |