line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::SortNatural; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
42949
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
4
|
use base qw( Template::Plugin::VMethods ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
731
|
|
6
|
1
|
|
|
1
|
|
13723
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
58
|
|
7
|
1
|
|
|
1
|
|
209
|
use Sort::Naturally; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @LIST_OPS = qw( sortn ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Template::Plugin::SortNatural - Sort lists natural with Sort::Naturally |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
[% USE SortNatural; |
20
|
|
|
|
|
|
|
foo.nsort; |
21
|
|
|
|
|
|
|
%] |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sort lexically, but sort numeral parts numerically |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 sortn( ) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Returns a new sorted arrayref. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub sortn { |
37
|
|
|
|
|
|
|
my $list = shift; |
38
|
|
|
|
|
|
|
if ( ref $list eq 'ARRAY' ) { |
39
|
|
|
|
|
|
|
return nsort(@{$list}); |
40
|
|
|
|
|
|
|
} else { |
41
|
|
|
|
|
|
|
croak "sort_by only works with ARRAY references"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |