my @keys = sort { @{$info{$b}}[$index] <=> @{$info{$a}}[$index] #compare plain numeric values || length($b) <=> length($a) #if there are matching vals comapre key length || $a cmp $b #compare chr if ya gotta } keys %info;