in reply to Re^3: Sorting HOH
in thread Sorting HOH
Try a Schwarzian transform based code:
After it you receive an array with ( Key1, Key2, Value ).use strict; use Data::Dumper; my %data; #-- original sample $data{1} = {'a' => 10, 'b' => 5, 'c' => 20 }; $data{2} = {'a' => 90, 'b' => 15, 'c' => 40 }; #-- my @Top = sort { $a->[2] <=> $b->[2] } map { my $h = $_; map { [ $h, $_, $data{$h}->{$_} ] } keys %{$data{$h}}; } keys %data; print Dumper(\@Top);
On Schuartzian transformation you receive the original data format sorted, but you don't need it here.
--
Marco Antonio
Rio-PM
|
|---|