According to your following array:
$cal[$year][$month] = $event;
and taking into account that $year and $month are both numeric (if not, just cast them).
For ordering both years and months in ASCENDING order, do:
ksort($cal); //sort years
foreach($cal as &$arr) {
ksort($arr); //sort months
}
if you want it in DESCENDING order, do:
krsort($cal); //sort years
foreach($cal as &$arr) {
krsort($arr); //sort months
}
you can interchange ksort() and krsort() in both examples if you want a mix sort, like years ASCENDING and months DESCENDING.