line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pipe::Tube::Sort; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
29
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Pipe::Tube'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
321
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
3
|
|
|
3
|
0
|
5
|
my ($self, $expr) = @_; |
12
|
3
|
100
|
|
|
|
21
|
$self->logger("Receiving the sort expression: '" . (defined $expr ? $expr : '') . "'"); |
13
|
3
|
|
|
|
|
6
|
$self->{expr} = $expr; |
14
|
3
|
|
|
|
|
8
|
$self->{data} = []; |
15
|
3
|
|
|
|
|
10
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub run { |
19
|
35
|
|
|
35
|
0
|
66
|
my ($self, @input) = @_; |
20
|
35
|
|
|
|
|
37
|
push @{ $self->{data} }, @input; |
|
35
|
|
|
|
|
72
|
|
21
|
35
|
|
|
|
|
88
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub finish { |
25
|
3
|
|
|
3
|
0
|
6
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
|
27
|
3
|
100
|
|
|
|
20
|
$self->logger("The sort expression: " . (defined $self->{expr} ? $self->{expr} : '')); |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
5
|
my $sub = $self->{expr}; |
30
|
3
|
|
|
|
|
5
|
my @sorted; |
31
|
3
|
100
|
|
|
|
7
|
if (defined $sub) { |
32
|
2
|
|
|
|
|
4
|
@sorted = sort { $sub->($a, $b) } @{ $self->{data} }; |
|
29
|
|
|
|
|
95
|
|
|
2
|
|
|
|
|
10
|
|
33
|
|
|
|
|
|
|
} else { |
34
|
1
|
|
|
|
|
2
|
@sorted = sort @{ $self->{data} }; |
|
1
|
|
|
|
|
10
|
|
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
45
|
return @sorted; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|