Kaydet (Commit) 94c1836f authored tarafından Tim Retout's avatar Tim Retout Kaydeden (comit) Michael Meeks

Inline and simplify installer::sorter::sort_array_of_hashes_numerically.

üst 14e6a83c
...@@ -60,34 +60,4 @@ sub sorting_array_of_hashes ...@@ -60,34 +60,4 @@ sub sorting_array_of_hashes
} }
} }
######################################################
# Sorting an array of hashes with a numerical value
######################################################
sub sort_array_of_hashes_numerically
{
my ($arrayref, $sortkey) = @_;
for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
{
my $onehashunder = ${$arrayref}[$i];
my $sortvalueunder = $onehashunder->{$sortkey};
for ( my $j = $i + 1; $j <= $#{$arrayref}; $j++ )
{
my $onehashover = ${$arrayref}[$j];
my $sortvalueover = $onehashover->{$sortkey};
if ( $sortvalueunder > $sortvalueover)
{
${$arrayref}[$i] = $onehashover;
${$arrayref}[$j] = $onehashunder;
$onehashunder = $onehashover;
$sortvalueunder = $sortvalueover;
}
}
}
}
1; 1;
...@@ -31,7 +31,6 @@ use installer::existence; ...@@ -31,7 +31,6 @@ use installer::existence;
use installer::exiter; use installer::exiter;
use installer::files; use installer::files;
use installer::globals; use installer::globals;
use installer::sorter;
use installer::worker; use installer::worker;
use installer::windows::idtglobal; use installer::windows::idtglobal;
use installer::windows::language; use installer::windows::language;
...@@ -244,8 +243,7 @@ sub collect_modules_recursive ...@@ -244,8 +243,7 @@ sub collect_modules_recursive
{ {
if ( $directparent->{$modulegid} eq $parentid ) if ( $directparent->{$modulegid} eq $parentid )
{ {
my %childhash = ( "gid" => "$modulegid", "Sortkey" => "$directsortkey->{$modulegid}"); push @allchildren, [ $directsortkey->{$modulegid}, $modulegid ];
push(@allchildren, \%childhash);
$childrenexist = 1; $childrenexist = 1;
} }
} }
...@@ -255,14 +253,13 @@ sub collect_modules_recursive ...@@ -255,14 +253,13 @@ sub collect_modules_recursive
if ( $childrenexist ) if ( $childrenexist )
{ {
# Sort children # Sort children
installer::sorter::sort_array_of_hashes_numerically(\@allchildren, "Sortkey"); @allchildren = map { $_->[1] }
sort { $a->[0] <=> $b->[0] }
@allchildren;
# Adding children to new array # Adding children to new array
my $childhashref; foreach my $gid ( @allchildren )
foreach $childhashref ( @allchildren )
{ {
my $gid = $childhashref->{'gid'};
# Saving all lines, that have this 'gid' # Saving all lines, that have this 'gid'
my $unique; my $unique;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment