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