I basically have this code which determines the number of same dates in an array:
function get_archives_html ($blog) {
//tag array to store arrays with same tag
$count_tags = array();
//store output
$output = '';
foreach($blog as $id) {
//abbreviate date name
$originalDate = $id["date"]["year"].'-'.$id["date"]["month"].'-'.$id["date"]["day"];
$abbrevDate = date("F, Y", strtotime($originalDate));
if(!isset($count_tags[$abbrevDate])) {
$count_tags[$abbrevDate] = 0;
}
++$count_tags[$abbrevDate];
}
// Sort your tags from hi to low
//arsort($count_tags);
var_dump($count_tags);
foreach($count_tags as $month=>$id) {
$output.= '<p><a href="#">'. $month.($id > 1 ? ' ('.$id .')' : '').'</a></p>';
}
return $output;
}
The output would look like this:
$arr = array(
"November, 2016" => "2",
"October, 2016" => "5",
"October, 2017" => "3",
"September, 2017" => "6"
);
Now, I use the keys to display it on the html. Problem is that it is not arranged properly by date but rather by alphabet.
So, my question is, how can I sort this array by key and by date. Example would be October, 2016, November 2016, September, 2017, October 2014 Thank you