my @keys_in_epoch_order = map { $$_[1] } # isolate key sort { $$b[0] <=> $$a[0] } # sort by epoch numerical descending map { [ $out_hash{$_}{EPOCH}, $_ ] } # arrays of epoch, key keys %out_hash; # source keys