From a0a26da3bcdfda771f6b2fd2e4d78ea38e2101d2 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 20 Aug 2010 12:44:40 -0500 Subject: [PATCH] remove WebGUI::Utility::sortHashDescending --- lib/WebGUI/Utility.pm | 25 +------------------------ t/Utility.t | 2 -- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index b2543a39a..776b9f6b9 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -23,7 +23,7 @@ use Net::CIDR::Lite; our @ISA = qw(Exporter); our @EXPORT = qw(&isInSubnet - &sortHashDescending &sortHash &isIn &randint &round &scalarEquals + &sortHash &isIn &randint &round &scalarEquals ); @@ -43,7 +43,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme $integer = randint($low,$high); $rounded = round($number, $digits); %hash = sortHash(%hash); - %hash = sortHashDescending(%hash); =head1 METHODS @@ -211,27 +210,5 @@ sub sortHash { return %newHash; } -#------------------------------------------------------------------- - -=head2 sortHashDescending ( hash ) - -Sorts a hash in decending order by its values. Returns a Tie::IxHash. -You must assign this to a similarly tied hash to preserve the order. - -=head3 hash - -A hash to be sorted. - -=cut - -sub sortHashDescending { - my %hash = @_; - tie my %newHash, 'Tie::IxHash'; - for my $key ( sort { $hash{$b} cmp $hash{$a} } keys %hash ) { - $newHash{ $key } = $hash{ $key }; - } - return %newHash; -} - 1; diff --git a/t/Utility.t b/t/Utility.t index 4a240d3f4..0eac303de 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -47,9 +47,7 @@ is(WebGUI::Utility::round(47.6, 0), 48, 'round() - rounds up, too'); tie my %hash2, 'Tie::IxHash'; tie my %hash3, 'Tie::IxHash'; %hash2 = WebGUI::Utility::sortHash(%hash1); - %hash3 = WebGUI::Utility::sortHashDescending(%hash1); is_deeply([keys %hash2], [qw/e c b d a/], 'sortHash'); - is_deeply([keys %hash3], [qw/a d b c e/], 'sortHashDescending'); } #####################################################################