summaryrefslogtreecommitdiffstats
path: root/solenv
diff options
context:
space:
mode:
authorTim Retout <tim@retout.co.uk>2012-02-15 20:08:57 +0000
committerMichael Meeks <michael.meeks@suse.com>2012-02-16 13:46:13 +0000
commit51f8f151780b6514d515b739e3167f36eb30787c (patch)
tree8553e2467161ba7119995e9c6219186311fe4332 /solenv
parentAdd tests for installer::sorter (diff)
downloadcore-51f8f151780b6514d515b739e3167f36eb30787c.tar.gz
core-51f8f151780b6514d515b739e3167f36eb30787c.zip
Simplify installer::sorter::sorting_array_of_hashes.
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/modules/installer/sorter.pm24
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;