I'm not entirely sure what sort order you're expecting there. You're not sorting the timestamps; you're also not sorting the data, merely the keys for each piece of data, so that the keys will always appear in lexicographical order. For instance, if for each chunk of data and each timestamp, your hash contained values for e.g. IP, REFERER and URL, you'd always get them in that order.
I take it you'd like to sort by timestamp? Simply add a sort in foreach $date ( keys %{ $data{$cat} }) {, like so (I've also taken the liberty of adding my declarations so the script will compile under use strict, and removing the HTML bits so that the output's easier to read):
#!/usr/bin/perl
use feature qw/say/;
use warnings;
use strict;
my %data = (
1 => {
"1405799856" => { IP => "79.223.46.211" },
"1405879428" => { IP => "79.200.95.44" },
"1405702121" => { IP => "87.149.76.154" },
"1407101135" => { IP => "188.138.41.140" },
"1406108233" => { IP => "82.139.192.95" },
"1407162997" => { IP => "87.149.66.39" },
"1405810508" => { IP => "80.187.110.214" },
"1405791762" => { IP => "84.159.197.17" },
"1405870826" => { IP => "2.246.106.240" },
"1406040423" => { IP => "87.154.119.73" },
"1405810525" => { IP => "85.22.101.198" },
"1405620262" => { IP => "87.149.72.59" },
"1405603261" => { IP => "178.12.215.30" },
"1405806556" => { IP => "80.187.102.26" },
}
);
foreach my $cat ( keys %data ) {
foreach my $date ( sort keys %{ $data{$cat} }) {
foreach my $data_type (sort { $a cmp $b } keys %{ $data{$cat}{
+$date} }) {
say "$date\t$data{$cat}{$date}{$data_type}";
}
}
}
EDIT: added a few characters that didn't copy'n'paste, thanks redbull2012.