in reply to Pingu can't sort a hash

Hi Pingu, here follows one of the very many ways to do it.
#!/usr/bin/perl -w use strict; # Saves me from worrying about csv stuff. # $results is a reference to a hash. my $results = { x => [1,3,4,5,6], y => [14,6,7,8,5], z => [6,7,8,5,3] }; # first we dereference our hash, then we check # our index... foreach (sort { return $$results{$a}->[0] <=> $$results{$b}->[0]; } keys %$results) { print "key = $_\narray =\n"; foreach my $i (0..4) { print $$results{$_}->[$i]."\n"; } }
Works like a charm for me. :)