Vous les triez dans la requête, puis vous les imprimez dans cet ordre. Vous devrez détecter les changements d'année, pour imprimer l'en-tête de l'année :
$sql = "SELECT YEAR(FROM_UNIXTIME(timestamp)) AS YEAR,
MONTHNAME(FROM_UNIXTIME(timestamp)) AS MONTH,
COUNT(*) AS TOTAL
FROM NEWS GROUP BY YEAR, MONTH ORDER BY YEAR DESC, MONTH ";
$newsdata = DataAccess::ArrayFetch($sql);
$currentYear = null;
foreach($newsdata AS $news){
if ($currentYear != $news['YEAR']){
echo '<h2>'.$news['YEAR'].'<h2>';
$currentYear = $news['YEAR'];
}
echo '<dd>'.$news['MONTH'].'<dd><dt>'.$news['TOTAL'].'</dt>';
}