sub shift_sort { my %hash = (1 => { foo => bar }, 2 => { baz => bletch }); shift @{ sort( { $a <=> $b } keys (%hash)) }; # doesnt work my @foo = sort( { $a <=> $b } keys (%hash)); shift @foo; # works }