Small typo in the aksort function I just submitted. Here's the entire thing again, with the correction noted:
<?php
function aksort(&$array,$valrev=false,$keyrev=false) {
if ($valrev) { arsort($array); } else { asort($array); }
$vals = array_count_values($array);
$i = 0;
foreach ($vals AS $val=>$num) {
$first = array_splice($array,0,$i);
$tmp = array_splice($array,0,$num);
if ($keyrev) { krsort($tmp); } else { ksort($tmp); }
$array = array_merge($first,$tmp,$array);
unset($tmp);
$i = $i+$num;
// Fixed from previous post: $i = $num;
}
}
?>