Use array_count_values() to see how often each value occurs then use that in the custom sort function used by uasort().
function freq_sort($a, $b) {
global $k;
if ($k[$a] == $k[$b]) return 0;
return ($k[$a] > $k[$b]) ? -1 : 1;
}
$array = array(1,2,1,3,2,4,5,2,3,4,2,5,1,1,2,3,4,3,2,1,2);
$k = array_count_values($array);
uasort($array, 'freq_sort');
// check results
echo '<pre>', print_r($array, true), '</pre>';