diff options
author | Tim Retout <tim@retout.co.uk> | 2012-02-15 20:08:57 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-02-16 13:46:13 +0000 |
commit | 51f8f151780b6514d515b739e3167f36eb30787c (patch) | |
tree | 8553e2467161ba7119995e9c6219186311fe4332 /solenv | |
parent | 01fde2e939cbc4aeeb15978febb5e2fa0396c125 (diff) |
Simplify installer::sorter::sorting_array_of_hashes.
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/modules/installer/sorter.pm | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/solenv/bin/modules/installer/sorter.pm b/solenv/bin/modules/installer/sorter.pm index 54e5c34c516b..b08dd80c31f8 100644 --- a/solenv/bin/modules/installer/sorter.pm +++ b/solenv/bin/modules/installer/sorter.pm @@ -44,26 +44,10 @@ sub sorting_array_of_hashes { 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 gt $sortvalueover) - { - ${$arrayref}[$i] = $onehashover; - ${$arrayref}[$j] = $onehashunder; - - $onehashunder = $onehashover; - $sortvalueunder = $sortvalueover; - } - } - } + @$arrayref = map { $_->[1] } + sort { $a->[0] cmp $b->[0] } + map { [$_->{$sortkey}, $_] } + @$arrayref; } 1; |